63 lines
1.8 KiB
YAML
63 lines
1.8 KiB
YAML
---
|
|
# Tasks for setting custom facts.
|
|
- name: "Setting custom facts."
|
|
ansible.builtin.set_fact:
|
|
enable_cloudinit: "{{ enable_cloudinit | default('false') }}"
|
|
|
|
# Tasks for configuring SSH for public key authentication.
|
|
- name: "Configuring SSH for Public Key Authentication."
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/ssh/sshd_config
|
|
regexp: '^PubkeyAuthentication'
|
|
line: 'PubkeyAuthentication yes'
|
|
|
|
# Tasks for setting the hostname.
|
|
- name: "Setting the hostname."
|
|
ansible.builtin.hostname:
|
|
name: "localhost"
|
|
|
|
# Tasks for restarting the SSH daemon.
|
|
- name: "Restarting the SSH daemon."
|
|
ansible.builtin.systemd:
|
|
name: ssh
|
|
state: restarted
|
|
daemon_reload: true
|
|
|
|
# Tasks for disabling systemd-tmpfiles.
|
|
- name: "Disabling systemd-tmpfiles."
|
|
ansible.builtin.replace:
|
|
path: /usr/lib/tmpfiles.d/tmp.conf
|
|
regexp: '^D'
|
|
replace: '#D'
|
|
|
|
# Tasks for configuring cloud-init.
|
|
- name: "Configuring cloud-init."
|
|
block:
|
|
- name: "Message: Configuring cloud-init"
|
|
ansible.builtin.debug:
|
|
msg: "Configuring cloud-init"
|
|
- ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
|
|
- /etc/cloud/cloud.cfg.d/99-installer.cfg
|
|
- /etc/netplan/00-installer-config.yaml
|
|
- ansible.builtin.copy:
|
|
content: 'datasource_list: [ VMware, OVF, None ]'
|
|
dest: /etc/cloud/cloud.cfg.d/90_dpkg.cfg
|
|
when: enable_cloudinit == 'true'
|
|
|
|
# Tasks for setting SSH keys to regenerate.
|
|
- name: "Setting SSH keys to regenerate."
|
|
ansible.builtin.copy:
|
|
dest: /etc/rc.local
|
|
content: |
|
|
#!/bin/bash
|
|
if test -z "$(find /etc/ssh/ -iname 'ssh_host_*_key*')"; then
|
|
dpkg-reconfigure openssh-server
|
|
fi
|
|
exit 0
|
|
mode: 0755
|
|
|