Commit f6977acc by Feanil Patel

Put all keys in the authorized_keys file.

parent dd0ae966
...@@ -114,28 +114,21 @@ ...@@ -114,28 +114,21 @@
# 2014/10/14 - using curl instead of get_url because # 2014/10/14 - using curl instead of get_url because
# get_url was failing due to certificate verification errors # get_url was failing due to certificate verification errors
- name: copy github key[s] to .ssh/authorized_keys2 - name: get github key[s]
shell: > shell: >
curl https://github.com/{{ item.name }}.keys -o /home/{{ item.name }}/.ssh/authorized_keys2 curl https://github.com/{{ item.name }}.keys
sudo_user: "{{ item.name }}" sudo_user: "{{ item.name }}"
when: item.github is defined and item.get('state', 'present') == 'present' when: item.github is defined and item.get('state', 'present') == 'present'
with_items: user_info with_items: user_info
register: github_keys
- name: set permissions on .ssh/authorized_keys2
file: > - name: update the authorized_keys file
dest=/home/{{ item.name }}/.ssh/authorized_keys2 template:
mode=0640 src="authorized_keys.j2"
owner={{ item.name }} dest="/home/{{ item.name }}/.ssh/authorized_keys"
when: item.github is defined and item.get('state', 'present') == 'present' owner="{{ item.name }}"
with_items: user_info mode="600"
when: item.get('state', 'present') == 'present'
- name: copy additional authorized keys
copy: >
content="{{ '\n'.join(item.authorized_keys) }}"
dest=/home/{{ item.name }}/.ssh/authorized_keys mode=0640
owner={{ item.name }}
mode=0440
when: item.authorized_keys is defined and item.get('state', 'present') == 'present'
with_items: user_info with_items: user_info
- name: create bashrc file for normal users - name: create bashrc file for normal users
......
# Keys from github
{% for github_key in github_keys.results -%}
{# None is lowercase in jinja... #}
{%- if github_key.changed -%}
{%- if github_key.item.name == item.name -%}
{{ github_key.stdout }}
{%- endif -%}
{%- endif -%}
{% endfor %}
{% if item.get('authorized_keys') %}
# Explicitly specified keys
{{ '\n'.join(item.authorized_keys) }}
{% endif %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment