|
|
|
@ -17,51 +17,41 @@ |
|
|
|
nictype: bridged |
|
|
|
nictype: bridged |
|
|
|
parent: "{{ lxd_bridge }}" |
|
|
|
parent: "{{ lxd_bridge }}" |
|
|
|
ipv4.address: "{{ container_ip }}" |
|
|
|
ipv4.address: "{{ container_ip }}" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: update container packages |
|
|
|
- name: update container packages |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- apk upgrade -U" |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- apk upgrade -U" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: install openssh, rsync, and shadow packages in containers |
|
|
|
- name: install openssh, rsync, and shadow packages in containers |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- apk add openssh rsync shadow" |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- \ |
|
|
|
when: not debug_skip |
|
|
|
apk add openssh rsync shadow python3" |
|
|
|
|
|
|
|
|
|
|
|
- name: "copy container sshd_config for {{ container_name }} to lxd host" |
|
|
|
- name: "copy container sshd_config for {{ container_name }} to lxd host" |
|
|
|
template: |
|
|
|
template: |
|
|
|
src: templates/sshd_config.j2 |
|
|
|
src: templates/sshd_config.j2 |
|
|
|
dest: "{{ tmp_sshd_config }}" |
|
|
|
dest: "{{ tmp_sshd_config }}" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: use lxc file push to get sshd_config into container |
|
|
|
- name: use lxc file push to get sshd_config into container |
|
|
|
command: "{{ lxc_cmd }} file push {{ tmp_sshd_config}} \ |
|
|
|
command: "{{ lxc_cmd }} file push {{ tmp_sshd_config}} \ |
|
|
|
{{ container_name }}/etc/ssh/sshd_config" |
|
|
|
{{ container_name }}/etc/ssh/sshd_config" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: mkdir /root/.ssh in {{ container_name }} |
|
|
|
- name: mkdir /root/.ssh in {{ container_name }} |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- mkdir -p /root/.ssh" |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- mkdir -p /root/.ssh" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: add controller public key to {{ container_name }} authorized keys |
|
|
|
- name: add controller public key to {{ container_name }} authorized keys |
|
|
|
command: "{{ lxc_cmd }} file push {{ tmp_pubkey }} \ |
|
|
|
command: "{{ lxc_cmd }} file push {{ tmp_pubkey }} \ |
|
|
|
{{ container_name }}/root/.ssh/authorized_keys \ |
|
|
|
{{ container_name }}/root/.ssh/authorized_keys \ |
|
|
|
--gid 0 --uid 0 --mode 600" |
|
|
|
--gid 0 --uid 0 --mode 600" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: make hash of a random password |
|
|
|
- name: make hash of a random password |
|
|
|
set_fact: |
|
|
|
set_fact: |
|
|
|
root_pass: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') | password_hash('sha512') }}" |
|
|
|
root_pass: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') | password_hash('sha512') }}" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: "set password to unlock root account (NOTE: still using pubkey only)" |
|
|
|
- name: "set password to unlock root account (NOTE: still using pubkey only)" |
|
|
|
shell: '{{ lxc_cmd }} exec {{ container_name }} -- usermod -p {{ root_pass }} root' |
|
|
|
shell: '{{ lxc_cmd }} exec {{ container_name }} -- usermod -p {{ root_pass }} root' |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: ensure sshd service is enabled |
|
|
|
- name: ensure sshd service is enabled |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- rc-update add sshd" |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- rc-update add sshd" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: ensure sshd service is enabled |
|
|
|
- name: ensure sshd service is started |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- rc-service sshd start" |
|
|
|
command: "{{ lxc_cmd }} exec {{ container_name }} -- rc-service sshd start" |
|
|
|
when: not debug_skip |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|