split ansible into roles
This commit is contained in:
parent
3544581bde
commit
97f93b02a8
10 changed files with 36 additions and 19 deletions
|
@ -1,4 +1,5 @@
|
||||||
[defaults]
|
[defaults]
|
||||||
|
roles_path=roles
|
||||||
inventory=inventory
|
inventory=inventory
|
||||||
interpreter_python=/usr/bin/python3
|
interpreter_python=/usr/bin/python3
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[targets]
|
|
||||||
|
|
||||||
192.168.30.7 ansible_connection=ssh ansible_user=root
|
|
1
ansible/inventory/host_vars/hermes.yml
Normal file
1
ansible/inventory/host_vars/hermes.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
internal_ip: 192.168.30.7
|
6
ansible/inventory/hosts.yml
Normal file
6
ansible/inventory/hosts.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
all:
|
||||||
|
hosts:
|
||||||
|
hermes:
|
||||||
|
ansible_connection: ssh
|
||||||
|
ansible_user: root
|
||||||
|
ansible_host: 192.168.30.7
|
17
ansible/roles/dnsmasq/tasks/main.yml
Normal file
17
ansible/roles/dnsmasq/tasks/main.yml
Normal 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
|
0
ansible/roles/nsd/tasks/main.yml
Normal file
0
ansible/roles/nsd/tasks/main.yml
Normal file
1
main.tf
1
main.tf
|
@ -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}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
Reference in a new issue