From d680b0dde430df6c414f9e5d35f9bcd9fa57eb2a Mon Sep 17 00:00:00 2001 From: djpbessems Date: Tue, 8 Jun 2021 09:24:39 +0200 Subject: [PATCH] Add ansible provisioner --- ansible/playbook.yml | 5 +++++ ansible/roles/os/tasks/main.yml | 14 ++++++++++++++ packer/preseed/UbuntuServer20.04/user-data | 2 +- packer/ubuntuserver20.04.pkr.hcl | 10 ++++------ 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 ansible/playbook.yml create mode 100644 ansible/roles/os/tasks/main.yml diff --git a/ansible/playbook.yml b/ansible/playbook.yml new file mode 100644 index 0000000..7c89e00 --- /dev/null +++ b/ansible/playbook.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + gather_facts: false + roles: + - os diff --git a/ansible/roles/os/tasks/main.yml b/ansible/roles/os/tasks/main.yml new file mode 100644 index 0000000..4b8c3fa --- /dev/null +++ b/ansible/roles/os/tasks/main.yml @@ -0,0 +1,14 @@ +- name: Delete cloud-init package + apt: + name: cloud-init + state: absent + purge: yes + autoclean: yes + autoremove: yes +- name: Delete cloud-init files + file: + path: {{ item }} + state: absent + loop: + - /etc/cloud + - /var/lib/cloud diff --git a/packer/preseed/UbuntuServer20.04/user-data b/packer/preseed/UbuntuServer20.04/user-data index aa7cb9d..945d634 100644 --- a/packer/preseed/UbuntuServer20.04/user-data +++ b/packer/preseed/UbuntuServer20.04/user-data @@ -20,7 +20,7 @@ autoinstall: identity: hostname: packer-template username: ubuntu - password: $6$E.3LG7StnEURoOWy$PTcyaJyS5HHFExctu5hWd.oH0LapJ9gXzUd62QfVDjza4rfrEy61NVLmlGE40R7eSBvWBkISvRabc2y0NQ/sy0 + password: $6$rounds=4096$ZKfzRoaQOtc$M.fhOsI0gbLnJcCONXz/YkPfSoefP4i2/PQgzi2xHEi2x9CUhush.3VmYKL0XVr5JhoYvnLfFwqwR/1YYEqZy/ ssh: install-server: yes allow-pw: true diff --git a/packer/ubuntuserver20.04.pkr.hcl b/packer/ubuntuserver20.04.pkr.hcl index 7ce69ac..1b38a97 100644 --- a/packer/ubuntuserver20.04.pkr.hcl +++ b/packer/ubuntuserver20.04.pkr.hcl @@ -27,8 +27,7 @@ source "vsphere-iso" "ubuntuserver" { communicator = "ssh" ssh_username = "ubuntu" - ssh_password = "ubuntu" - // ssh_password = var.ssh_password + ssh_password = var.ssh_password ssh_timeout = "20m" ssh_handshake_attempts = "100" ssh_pty = true @@ -68,10 +67,9 @@ source "vsphere-iso" "ubuntuserver" { build { sources = ["source.vsphere-iso.ubuntuserver"] - // provisioner "file" { - // destination = "" - // source = "" - // } + provisioner "ansible" { + playbook_file = "ansible/playbook.yml" + } post-processor "shell-local" { inline = [