imfreedom/ansible

6268baf0fdae
Parents ea0f22c19be6
Children ff6b408e3bcf
Add a playbook for setting up libvirt hosts.
--- a/inventories/pidgin/hosts.yaml Fri Sep 17 22:46:57 2021 -0500
+++ b/inventories/pidgin/hosts.yaml Sat Sep 18 18:59:37 2021 -0500
@@ -29,14 +29,6 @@
- "system.qemuUserStatic=True"
teamcity_groups:
- "docker"
- grim-reaper03:
- ansible_host: reaper03
- teamcity_agent_name: grim-reaper03
- teamcity_properties:
- - "system.convey=True"
- - "system.qemuUserStatic=True"
- teamcity_groups:
- - "docker"
rekkanoryo-convey-00:
ansible_host: rekkanoryo-convey-00
teamcity_agent_name: rekkanoryo-convey-00
@@ -55,17 +47,6 @@
- "system.qemuUserStatic=True"
teamcity_groups:
- "docker"
- do_teamcity_convey_agents:
- hosts:
- fantail:
- ansible_user: root
- ansible_host: fantail.pidgin.im
- teamcity_agent_name: fantail
- teamcity_properties:
- - "system.convey=True"
- - "system.qemuUserStatic=True"
- teamcity_groups:
- - "docker"
teamcity_coverity_agents:
hosts:
grim-coverity:
@@ -74,6 +55,10 @@
teamcity_properties:
- "system.coverity=True"
- "env.PATH={{ ansible_env.PATH }}:{{ coverity_directory }}/bin"
+ teamcity_libvirt_hosts:
+ hosts:
+ grim-chariot:
+ ansible_host: chariot
teamcity_simple_agents:
hosts:
grim-beastie:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/libvirt/tasks/debian.yaml Sat Sep 18 18:59:37 2021 -0500
@@ -0,0 +1,13 @@
+---
+- name: install
+ apt:
+ name:
+ - bridge-utils
+ - libvirt-clients
+ - libvirt-daemon
+ - libvirt-daemon-system
+ state: present
+ force_apt_get: true
+- name: setup default network
+ include_tasks: "network.yaml"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/libvirt/tasks/main.yaml Sat Sep 18 18:59:37 2021 -0500
@@ -0,0 +1,4 @@
+---
+- include_tasks: debian.yaml
+ when: ansible_facts['os_family'] == "Debian"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/roles/libvirt/tasks/network.yaml Sat Sep 18 18:59:37 2021 -0500
@@ -0,0 +1,13 @@
+---
+- name: check for default network
+ shell: virsh net-info default # noqa 305
+ register: create_network
+ changed_when: "create_network.rc != 0"
+- name: create default network
+ shell: virsh net-create --file=/usr/share/libvirt/networks/default.xml # noqa 305
+ when: create_network|bool
+- name: enable default network
+ shell: virsh net-start default # noqa 301 305
+- name: set default network to autostart
+ shell: virsh net-autostart default # noqa 301 305
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/teamcity_libvirt_hosts.yaml Sat Sep 18 18:59:37 2021 -0500
@@ -0,0 +1,6 @@
+---
+- hosts: teamcity_libvirt_hosts
+ roles:
+ - role: update
+ - role: cron_apt
+ - role: libvirt