Eugene Knoxville
2015-07-21 12:48:48 UTC
Hello,
Have some troubles with including var files. What I need? I keep
authorized_keys files for each user in a separate file. For exmpl, let's
say that hostname is f22.
Playbook f22.yml:
---
- hosts: f22
tasks:
- include: tasks/mainsoftware.yml
vars_files:
- /etc/ansible/files/pub_keys/f22/ssh_user
- /etc/ansible/files/pub_keys/f22/allow_users
roles:
- { role: ssh.role, ssh_user: "{{ ssh_user}}" , allow_users:"{{
allow_users }}" }
/etc/ansible/files/pub_keys/f22/ssh_user:
---
ssh_user: test1
ssh_user: test2
/etc/ansible/files/pub_keys/f22/allow_users:
---
allow_users: test1 test2
ssh.role file:
- name: Creating authorized_keys file
template: src=root-keys dest=/root/.ssh/authorized_keys mode=600 owner=0
group=0
- name: Creating id_rsa file
template: src=id_rsa dest=/root/.ssh/id_rsa mode=600 owner=0 group=0
- name: sshd configuration file update
template: src=sshd_config
dest=/etc/ssh/sshd_config
backup=yes
owner=0 group=0 mode=0644
validate='/usr/sbin/sshd -T -f %s'
when: ansible_system == "Linux"
notify:
- restart sshd
- name: Create users
user: name="{{ ssh_user }}" generate_ssh_key=no comment="{{ ssh_user }}
user"
# with_items: "{{ ssh_user }}"
- name: Add pub files
authorized_key: user="{{ ssh_user }}" key="{{ item }}"
with_file: /etc/ansible/files/pub_keys/{{ansible_hostname}}/{{ ssh_user
}}.pub
# with_items: "{{ ssh_user }}"
- name: add AllowUsers
lineinfile: dest=/etc/ssh/sshd_config line="AllowUsers {{ allow_users }}"
notify:
- restart sshd
- name: sshd configuration file update FreeBSD
template: src=sshd_config_free
dest=/etc/ssh/sshd_config
backup=yes
owner=0 group=0 mode=0644
validate='/usr/sbin/sshd -T -f %s'
when: ansible_system == "FreeBSD"
notify:
- restart sshd
*After applying, I'm getting:*
<Loading Image...>
Please help :)
Have some troubles with including var files. What I need? I keep
authorized_keys files for each user in a separate file. For exmpl, let's
say that hostname is f22.
Playbook f22.yml:
---
- hosts: f22
tasks:
- include: tasks/mainsoftware.yml
vars_files:
- /etc/ansible/files/pub_keys/f22/ssh_user
- /etc/ansible/files/pub_keys/f22/allow_users
roles:
- { role: ssh.role, ssh_user: "{{ ssh_user}}" , allow_users:"{{
allow_users }}" }
/etc/ansible/files/pub_keys/f22/ssh_user:
---
ssh_user: test1
ssh_user: test2
/etc/ansible/files/pub_keys/f22/allow_users:
---
allow_users: test1 test2
ssh.role file:
- name: Creating authorized_keys file
template: src=root-keys dest=/root/.ssh/authorized_keys mode=600 owner=0
group=0
- name: Creating id_rsa file
template: src=id_rsa dest=/root/.ssh/id_rsa mode=600 owner=0 group=0
- name: sshd configuration file update
template: src=sshd_config
dest=/etc/ssh/sshd_config
backup=yes
owner=0 group=0 mode=0644
validate='/usr/sbin/sshd -T -f %s'
when: ansible_system == "Linux"
notify:
- restart sshd
- name: Create users
user: name="{{ ssh_user }}" generate_ssh_key=no comment="{{ ssh_user }}
user"
# with_items: "{{ ssh_user }}"
- name: Add pub files
authorized_key: user="{{ ssh_user }}" key="{{ item }}"
with_file: /etc/ansible/files/pub_keys/{{ansible_hostname}}/{{ ssh_user
}}.pub
# with_items: "{{ ssh_user }}"
- name: add AllowUsers
lineinfile: dest=/etc/ssh/sshd_config line="AllowUsers {{ allow_users }}"
notify:
- restart sshd
- name: sshd configuration file update FreeBSD
template: src=sshd_config_free
dest=/etc/ssh/sshd_config
backup=yes
owner=0 group=0 mode=0644
validate='/usr/sbin/sshd -T -f %s'
when: ansible_system == "FreeBSD"
notify:
- restart sshd
*After applying, I'm getting:*
<Loading Image...>
Please help :)
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/323a5abd-7420-4bd2-92f8-e7550e953ebd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/323a5abd-7420-4bd2-92f8-e7550e953ebd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.