From 1a6c710263affd545d29d910e982a57ff7e833cc Mon Sep 17 00:00:00 2001 From: Lilian Roller Date: Fri, 8 Mar 2019 11:33:28 +0100 Subject: [PATCH] improve optional keychain handling --- defaults/main.yml | 6 +++++- tasks/main.yml | 8 ++++++-- templates/bashrc | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 876ce02..89259b8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,11 @@ --- +# should we install keychain for ssh-add support? +install_keychain: False +# some bash variables bash: - bashrc: 'eval $(keychain --eval --quiet id_ed25519)' + bashrc: '' + keychain: 'eval $(keychain --eval --quiet id_ed25519)' nextcloud: false nm: false pwgen: true diff --git a/tasks/main.yml b/tasks/main.yml index 33c0971..0977923 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,7 +5,8 @@ dnf: name: libselinux-python state: latest - when: ansible_distribution == "Fedora" + when: + - ansible_distribution == "Fedora" - name: install keychain to support ssh agent become: yes @@ -14,6 +15,7 @@ state: latest when: - ansible_os_family != 'RedHat' + - install_keychain - name: install keychain on centos become: yes @@ -22,7 +24,9 @@ - http://packages.psychotic.ninja/7/base/x86_64/RPMS//keychain-2.8.0-3.el7.psychotic.noarch.rpm - libselinux-python state: present - when: ansible_os_family == 'RedHat' + when: + - ansible_os_family == 'RedHat' + - install_keychain - name: Create a global bashrc configuration become: yes diff --git a/templates/bashrc b/templates/bashrc index 0271e3e..19b916a 100644 --- a/templates/bashrc +++ b/templates/bashrc @@ -15,6 +15,9 @@ export PATH PS1='$(if [[ $(id -u) -ne 0 ]];then echo "\[\033[01;33m\]"; else echo "\[\033[01;31m\]"; fi) $(if [[ $? == 0 ]]; then printf "\xE2\x9D\xA4"; fi) \[\033[01;32m\]\u\[\033[01;36m\]@\[\033[01;32m\]\H\[\033[01;34m\] <\A> \[\033[01;35m\] \j \[\033[01;36m\] \w \[\033[01;33m\]\n\[\033[01;33m\] $(git branch 2>/dev/null | sed -n "s/* \(.*\)/\1 /p")$\[\033[01;00m\] ' {{ bash['bashrc'] }} +{% if install_keychain %} +{{ bash['keychain'] }} +{% endif %} # User specific aliases and functions alias ll="ls -all"