aboutsummaryrefslogtreecommitdiff
path: root/roles/ssh_keys/tasks
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2016-10-03 11:43:00 -0400
committerB Stack <bgstack15@gmail.com>2016-10-03 11:43:00 -0400
commit17c0b3e049ec09a6605d18c9325a5a69d54db8f6 (patch)
tree029c5ba12793fdec2e9407285a59bb3e50d19747 /roles/ssh_keys/tasks
parentreadme (diff)
downloadansible01-17c0b3e049ec09a6605d18c9325a5a69d54db8f6.tar.gz
ansible01-17c0b3e049ec09a6605d18c9325a5a69d54db8f6.tar.bz2
ansible01-17c0b3e049ec09a6605d18c9325a5a69d54db8f6.zip
added sudo
Diffstat (limited to 'roles/ssh_keys/tasks')
-rw-r--r--roles/ssh_keys/tasks/main.yml.2016-10-03.0163
1 files changed, 63 insertions, 0 deletions
diff --git a/roles/ssh_keys/tasks/main.yml.2016-10-03.01 b/roles/ssh_keys/tasks/main.yml.2016-10-03.01
new file mode 100644
index 0000000..89d8d89
--- /dev/null
+++ b/roles/ssh_keys/tasks/main.yml.2016-10-03.01
@@ -0,0 +1,63 @@
+---
+- name: ssh_keys get vars
+ include_vars: default.yml
+
+- name: ssh_keys get OS vars
+ include_vars: '{{ item }}'
+ with_first_found:
+ - '{{ ansible_distribution }}.yml'
+ - default.yml
+
+#- shell: echo "{{ item | basename | regex_replace('\.pubkeys?$','') }}"
+# with_fileglob:
+# - '*.pubkey'
+# - '*.pubkeys'
+# register: users_to_check
+
+#- debug: var=ssh_key_strings
+#- debug: var=ssh_key_files
+
+- stat: path='{{ master_home_dir}}/{{ item.user }}/.ssh'
+ with_items:
+ - '{{ ssh_key_strings }}'
+ register: "s"
+ when: ssh_key_strings is defined
+
+- stat: path='{{ master_home_dir}}/{{ item.user }}/.ssh'
+ with_items:
+ - '{{ ssh_key_files }}'
+ register: "r"
+ when: ssh_key_files is defined
+
+#- debug: msg='{{ item.stat.exists }}'
+# with_flattened:
+# - '{{ r.results }}'
+
+- name: ssh_keys deploy keys from files
+ template:
+ src: "roles/ssh_keys/files/{{ item.item.file }}"
+ dest: '{{ master_home_dir }}/{{ item.item.user }}/.ssh/authorized_keys'
+ mode: 0600
+ owner: '{{ item.item.user }}'
+ with_items:
+ - '{{ r.results }}'
+ when:
+ - item.stat.exists is defined
+ - '{{ item.stat.exists }}'
+ - r is defined
+
+- name: ssh_keys deploy keys from strings
+ lineinfile:
+ line: '{{ item.item.string }}'
+ regexp: "{{ item.item.string | regex_replace('^(.{40}).*$','\\1') }}"
+ dest: '{{ master_home_dir }}/{{ item.item.user }}/.ssh/authorized_keys'
+ mode: 0600
+ owner: '{{ item.item.user }}'
+ create: yes
+ state: present
+ with_items:
+ - '{{ s.results }}'
+ when:
+ - item.stat.exists is defined
+ - '{{ item.stat.exists }}'
+ - s is defined
bgstack15