From f40889370dcdaac696c49efa8d14852641e68476 Mon Sep 17 00:00:00 2001 From: djpbessems Date: Thu, 10 Jun 2021 11:39:42 +0200 Subject: [PATCH] Add logging;Move iso-file specifics to variable file;Housekeeping --- .../files/ansible_payload/playbook.yml | 2 +- ansible/roles/os/tasks/logging.yml | 5 +++++ ansible/roles/os/tasks/main.yml | 3 +++ packer/iso.auto.pkrvars.hcl | 2 ++ packer/ubuntuserver20.04.pkr.hcl | 4 ++-- packer/variables.pkr.hcl | 17 ++++++++++++++--- 6 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/os/tasks/logging.yml create mode 100644 packer/iso.auto.pkrvars.hcl diff --git a/ansible/roles/firstboot/files/ansible_payload/playbook.yml b/ansible/roles/firstboot/files/ansible_payload/playbook.yml index ffa17f7..ff818a9 100644 --- a/ansible/roles/firstboot/files/ansible_payload/playbook.yml +++ b/ansible/roles/firstboot/files/ansible_payload/playbook.yml @@ -1,5 +1,5 @@ --- -- hosts: localhost +- hosts: 127.0.0.1 connection: local gather_facts: false # become: true diff --git a/ansible/roles/os/tasks/logging.yml b/ansible/roles/os/tasks/logging.yml new file mode 100644 index 0000000..c786ef1 --- /dev/null +++ b/ansible/roles/os/tasks/logging.yml @@ -0,0 +1,5 @@ +- name: Enable crontab logging + ansible.builtin.lineinfile: + path: /etc/rsyslog.d/50-default.conf + regexp: '^#cron\.\*.*' + line: "cron.*\t\t\t\t./var/log/cron.log' diff --git a/ansible/roles/os/tasks/main.yml b/ansible/roles/os/tasks/main.yml index d0bb813..d896e50 100644 --- a/ansible/roles/os/tasks/main.yml +++ b/ansible/roles/os/tasks/main.yml @@ -4,6 +4,9 @@ - name: Remove cloud-init import_tasks: cloud-init.yml +- name: Configure default logging + import_tasks: logging.yml + - name: Configure services import_tasks: services.yml diff --git a/packer/iso.auto.pkrvars.hcl b/packer/iso.auto.pkrvars.hcl new file mode 100644 index 0000000..1f97c27 --- /dev/null +++ b/packer/iso.auto.pkrvars.hcl @@ -0,0 +1,2 @@ +iso_url = "sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2020.04/ubuntu-20.04.2-live-server-amd64.iso" +iso_checksum = "sha256:D1F2BF834BBE9BB43FAF16F9BE992A6F3935E65BE0EDECE1DEE2AA6EB1767423" diff --git a/packer/ubuntuserver20.04.pkr.hcl b/packer/ubuntuserver20.04.pkr.hcl index 3966ca5..7b3e35b 100644 --- a/packer/ubuntuserver20.04.pkr.hcl +++ b/packer/ubuntuserver20.04.pkr.hcl @@ -51,8 +51,8 @@ source "vsphere-iso" "ubuntuserver" { "packer/preseed/UbuntuServer20.04/meta-data" ] cd_label = "cidata" - iso_checksum = "sha256:D1F2BF834BBE9BB43FAF16F9BE992A6F3935E65BE0EDECE1DEE2AA6EB1767423" - iso_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2020.04/ubuntu-20.04.2-live-server-amd64.iso" + iso_url = var.iso_authenticatedurl + iso_checksum = var.iso_checksum shutdown_command = "echo '${var.ssh_password}' | sudo -S shutdown -P now" shutdown_timeout = "5m" diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index 59ddfa8..1f35e1c 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -1,6 +1,8 @@ variable "vcenter_server" {} variable "vsphere_username" {} -variable "vsphere_password" {} +variable "vsphere_password" { + sensitive = true +} variable "vsphere_host" {} variable "vsphere_datacenter" {} @@ -12,7 +14,16 @@ variable "vsphere_network" {} variable "vm_name" {} variable "vm_guestos" {} -variable "ssh_password" {} +variable "ssh_password" { + sensitive = true +} +variable "iso_url" {} +variable "iso_checksum" {} variable "repo_username" {} -variable "repo_password" {} \ No newline at end of file +variable "repo_password" { + sensitive = true +} +locals { + iso_authenticatedurl = "https://${var.repo_username}:${var.repo_password}@${var.iso_url}" +} \ No newline at end of file