feat: add steps to configure cloud-init

This commit is contained in:
AJ Schroeder
2024-07-12 15:15:27 -05:00
parent 57fbda310b
commit d55f323020
2 changed files with 36 additions and 11 deletions

View File

@@ -28,9 +28,29 @@
state: disabled state: disabled
policy: targeted policy: targeted
# Tasks for configuring cloud-init.
- block:
- name: "Message: Configuring cloud-init"
ansible.builtin.debug:
msg: "Configuring cloud-init"
- name: "Add Proxmox datasource"
ansible.builtin.copy:
content: "datasource_list: [ NoCloud, ConfigDrive ]"
dest: /etc/cloud/cloud.cfg.d/99_pve.cfg
- name: Enable cloud-init services
ansible.builtin.service:
name: "{{ item }}"
enabled: true
loop:
- cloud-config
- cloud-init
- cloud-init-local
- cloud-final
when: enable_cloudinit == 'true'
# Tasks for restarting the SSH daemon. # Tasks for restarting the SSH daemon.
- name: "Restarting the SSH daemon." - name: "Restarting the SSH daemon."
ansible.builtin.systemd: ansible.builtin.systemd:
name: sshd name: sshd
state: restarted state: restarted
daemon_reload: true daemon_reload: true

View File

@@ -31,13 +31,6 @@
ansible.builtin.hostname: ansible.builtin.hostname:
name: "localhost" name: "localhost"
# Tasks for restarting the SSH daemon.
- name: "Restarting the SSH daemon."
ansible.builtin.systemd:
name: sshd
state: restarted
daemon_reload: true
# Tasks for configuring cloud-init. # Tasks for configuring cloud-init.
- name: "Configuring cloud-init." - name: "Configuring cloud-init."
block: block:
@@ -45,8 +38,20 @@
ansible.builtin.debug: ansible.builtin.debug:
msg: "Configuring cloud-init" msg: "Configuring cloud-init"
- ansible.builtin.copy: - ansible.builtin.copy:
content: 'datasource_list: [ ConfigDrive, NoCloud ]' content: "datasource_list: [ NoCloud, ConfigDrive ]"
dest: /etc/cloud/cloud.cfg.d/90_dpkg.cfg dest: /etc/cloud/cloud.cfg.d/99_pve.cfg
- name: Enable cloud-init services
ansible.builtin.service:
name: "{{ item }}"
enabled: true
loop:
- cloud-init
- cloud-init-local
when: enable_cloudinit == 'true' when: enable_cloudinit == 'true'
... # Tasks for restarting the SSH daemon.
- name: "Restarting the SSH daemon."
ansible.builtin.systemd:
name: sshd
state: restarted
daemon_reload: true