diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index 1c0815a..7c6f1c2 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -1,4 +1,5 @@ [defaults] +roles_path=roles inventory=inventory interpreter_python=/usr/bin/python3 diff --git a/ansible/hermes.yml b/ansible/hermes.yml index 23eeea1..cfb49ba 100644 --- a/ansible/hermes.yml +++ b/ansible/hermes.yml @@ -1,7 +1,8 @@ --- - hosts: all gather_facts: no - tasks: + + pre_tasks: - name: Wait for host to come up wait_for: state: started @@ -28,19 +29,8 @@ apt: pkg: - qemu-guest-agent - - dnsmasq - dnsutils - - name: Disable systemd-resolved - systemd: - name: systemd-resolved - enabled: false - state: stopped - - name: Copy dnsmasq configuration - copy: - src: "dnsmasq.conf" - dest: "/etc/dnsmasq.conf" - - name: Enable dnsmasq - systemd: - name: dnsmasq - enabled: true - state: started + + roles: + - dnsmasq + - nsd diff --git a/ansible/inventory b/ansible/inventory deleted file mode 100644 index 2efb608..0000000 --- a/ansible/inventory +++ /dev/null @@ -1,3 +0,0 @@ -[targets] - -192.168.30.7 ansible_connection=ssh ansible_user=root diff --git a/ansible/inventory/host_vars/hermes.yml b/ansible/inventory/host_vars/hermes.yml new file mode 100644 index 0000000..73ada3f --- /dev/null +++ b/ansible/inventory/host_vars/hermes.yml @@ -0,0 +1 @@ +internal_ip: 192.168.30.7 diff --git a/ansible/inventory/hosts.yml b/ansible/inventory/hosts.yml new file mode 100644 index 0000000..a09a9b6 --- /dev/null +++ b/ansible/inventory/hosts.yml @@ -0,0 +1,6 @@ +all: + hosts: + hermes: + ansible_connection: ssh + ansible_user: root + ansible_host: 192.168.30.7 diff --git a/ansible/dnsmasq.conf b/ansible/roles/dnsmasq/files/dnsmasq.conf similarity index 100% rename from ansible/dnsmasq.conf rename to ansible/roles/dnsmasq/files/dnsmasq.conf diff --git a/ansible/roles/dnsmasq/tasks/main.yml b/ansible/roles/dnsmasq/tasks/main.yml new file mode 100644 index 0000000..1b2eb21 --- /dev/null +++ b/ansible/roles/dnsmasq/tasks/main.yml @@ -0,0 +1,17 @@ +- name: Install dnsmasq + apt: + name: dnsmasq +- name: Disable systemd-resolved + systemd: + name: systemd-resolved + enabled: false + state: stopped +- name: Copy dnsmasq configuration + copy: + src: "{{ role_path }}/files/dnsmasq.conf" + dest: "/etc/dnsmasq.conf" +- name: Enable dnsmasq + systemd: + name: dnsmasq + enabled: true + state: started diff --git a/ansible/roles/nsd/tasks/main.yml b/ansible/roles/nsd/tasks/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/main.tf b/main.tf index 21557d4..da980d7 100644 --- a/main.tf +++ b/main.tf @@ -54,6 +54,7 @@ resource "libvirt_domain" "ubuntu" { environment = { ANSIBLE_HOST_KEY_CHECKING = "False" + ANSIBLE_CONFIG = "${var.ansible_cfg}" } } diff --git a/variables.tf b/variables.tf index 4fbf4b7..ec3da61 100644 --- a/variables.tf +++ b/variables.tf @@ -23,3 +23,7 @@ variable "ansible_inventory" { variable "ansible_playbook" { default = "ansible/hermes.yml" } + +variable "ansible_cfg" { + default = "ansible/ansible.cfg" +}