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]
roles_path=roles
inventory=inventory
interpreter_python=/usr/bin/python3

View file

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

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 = {
ANSIBLE_HOST_KEY_CHECKING = "False"
ANSIBLE_CONFIG = "${var.ansible_cfg}"
}
}

View file

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