Optional non-empty passwords for the container user.
This commit is contained in:
parent
1b5f7ea0b5
commit
baba55e05a
2 changed files with 12 additions and 2 deletions
|
@ -7,6 +7,9 @@
|
||||||
become: yes
|
become: yes
|
||||||
vars:
|
vars:
|
||||||
contname: cont
|
contname: cont
|
||||||
|
## Password for the user 'ansible' in the container,
|
||||||
|
## leave empty to log in without password:
|
||||||
|
contpwd: ""
|
||||||
containers: "{{ range(0, 9 + 1) | list }}"
|
containers: "{{ range(0, 9 + 1) | list }}"
|
||||||
extra_pkgs: [apt-cacher-ng]
|
extra_pkgs: [apt-cacher-ng]
|
||||||
|
|
||||||
|
|
|
@ -103,14 +103,21 @@
|
||||||
cmd: chroot . sh -c "passwd -d ansible"
|
cmd: chroot . sh -c "passwd -d ansible"
|
||||||
args:
|
args:
|
||||||
chdir: /var/lib/machines/{{ contname }}00
|
chdir: /var/lib/machines/{{ contname }}00
|
||||||
when: user_account.changed | default(false)
|
when: user_account.changed | default(false) and contpwd | length == 0
|
||||||
|
|
||||||
|
- name: provide password for container ansible user
|
||||||
|
command:
|
||||||
|
cmd: chroot . sh -c "echo ansible:{{ contpwd }} | chpasswd"
|
||||||
|
args:
|
||||||
|
chdir: /var/lib/machines/{{ contname }}00
|
||||||
|
when: user_account.changed | default(true) and contpwd | length > 0
|
||||||
|
|
||||||
- name: allow empty passwords in ssh
|
- name: allow empty passwords in ssh
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /var/lib/machines/{{ contname }}00/etc/ssh/sshd_config
|
path: /var/lib/machines/{{ contname }}00/etc/ssh/sshd_config
|
||||||
insertafter: '#PermitEmptyPasswords no'
|
insertafter: '#PermitEmptyPasswords no'
|
||||||
line: 'PermitEmptyPasswords yes'
|
line: 'PermitEmptyPasswords yes'
|
||||||
when: user_account.changed | default(false)
|
when: user_account.changed | default(false) and contpwd | length == 0
|
||||||
|
|
||||||
- name: prepare directories
|
- name: prepare directories
|
||||||
file:
|
file:
|
||||||
|
|
Loading…
Add table
Reference in a new issue