๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ansible-playbooks/roles/container/tasks/preconf.yml

66 lines
2.3 KiB

- block:
- name: install basic dependencies
include_tasks: tasks/pct_command.yml
vars:
pct_command: "{{ item.pct_command }}"
chg_substr: "{{ item.chg_substr | d(omit) }}"
loop:
- pct_command: apk update
- pct_command: apk add python3
chg_substr: Installing
- pct_command: apk add dropbear
chg_substr: Installing
- pct_command: rc-update add dropbear
chg_substr: added to runlevel
- name: install dropbear-scp if this is not an ansible controller
include_tasks: tasks/pct_command.yml
vars:
pct_command: apk add dropbear-scp
chg_substr: Installing
when: (inventory_hostname != 'ansible') and ((primary_role is not defined) or (primary_role != 'ansible'))
and alpine_version is version('3.15', '<=')
- name: install openssh-sftp-server due to openssh 9 scp deprecation
include_tasks: tasks/pct_command.yml
vars:
pct_command: apk add openssh-sftp-server
chg_substr: Installing
when: alpine_version is version('3.16', '>=')
- name: start dropbear
include_tasks: tasks/pct_command.yml
vars:
pct_command: service dropbear start
chg_substr: \* Starting dropbear ... [ ok ]
when: (container_distro | lower) == 'alpine'
- block:
- name: install basic dependencies
include_tasks: tasks/pct_command.yml
vars:
pct_command: "{{ item.pct_command }}"
chg_substr: "{{ item.chg_substr | default(omit) }}"
loop:
- pct_command: apt-get --assume-yes update
- pct_command: apt-get --assume-yes install python3
chg_substr: The following NEW packages
- pct_command: apt-get --assume-yes install openssh-server
chg_substr: The following NEW packages
- pct_command: systemctl enable ssh.service
chg_substr: Synchronizing state
- name: edit sshd config
include_tasks: tasks/pct_command.yml
vars:
pct_command: "sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config"
- name: start sshd
include_tasks: tasks/pct_command.yml
vars:
pct_command: systemctl start ssh.service
when: (container_distro | lower) in ['debian', 'ubuntu']