split ansible into roles

This commit is contained in:
Pim Kunis 2023-03-17 17:26:03 +01:00
parent 3544581bde
commit 97f93b02a8
10 changed files with 36 additions and 19 deletions

View file

@ -1,4 +1,5 @@
[defaults] [defaults]
roles_path=roles
inventory=inventory inventory=inventory
interpreter_python=/usr/bin/python3 interpreter_python=/usr/bin/python3

View file

@ -1,7 +1,8 @@
--- ---
- hosts: all - hosts: all
gather_facts: no gather_facts: no
tasks:
pre_tasks:
- name: Wait for host to come up - name: Wait for host to come up
wait_for: wait_for:
state: started state: started
@ -28,19 +29,8 @@
apt: apt:
pkg: pkg:
- qemu-guest-agent - qemu-guest-agent
- dnsmasq
- dnsutils - dnsutils
- name: Disable systemd-resolved
systemd: roles:
name: systemd-resolved - dnsmasq
enabled: false - nsd
state: stopped
- name: Copy dnsmasq configuration
copy:
src: "dnsmasq.conf"
dest: "/etc/dnsmasq.conf"
- name: Enable dnsmasq
systemd:
name: dnsmasq
enabled: true
state: started

View file

@ -1,3 +0,0 @@
[targets]
192.168.30.7 ansible_connection=ssh ansible_user=root

View file

@ -0,0 +1 @@
internal_ip: 192.168.30.7

View file

@ -0,0 +1,6 @@
all:
hosts:
hermes:
ansible_connection: ssh
ansible_user: root
ansible_host: 192.168.30.7

View file

@ -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

View file

View file

@ -54,6 +54,7 @@ resource "libvirt_domain" "ubuntu" {
environment = { environment = {
ANSIBLE_HOST_KEY_CHECKING = "False" ANSIBLE_HOST_KEY_CHECKING = "False"
ANSIBLE_CONFIG = "${var.ansible_cfg}"
} }
} }

View file

@ -23,3 +23,7 @@ variable "ansible_inventory" {
variable "ansible_playbook" { variable "ansible_playbook" {
default = "ansible/hermes.yml" default = "ansible/hermes.yml"
} }
variable "ansible_cfg" {
default = "ansible/ansible.cfg"
}