From e22874986a13e213c2e60447ea236f6218fb73b9 Mon Sep 17 00:00:00 2001 From: nazunalika Date: Thu, 10 Dec 2020 11:19:24 -0700 Subject: [PATCH] docs and change from role to init --- ansible/README.md | 4 +- ansible/init-rocky-install-kvm-hosts.yml | 55 ++++++++++++++++++++++++ ansible/role-rocky-check-virt.yml | 6 --- ansible/role-rocky-install-kvm-hosts.yml | 25 ----------- 4 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 ansible/init-rocky-install-kvm-hosts.yml delete mode 100644 ansible/role-rocky-check-virt.yml delete mode 100644 ansible/role-rocky-install-kvm-hosts.yml diff --git a/ansible/README.md b/ansible/README.md index ae81acd..b504c3a 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -24,7 +24,9 @@ vars -> Global variables that are called with vars_files go here. This init-* -> Starting infrastructure playbooks that run solo or import other playbooks that start with import- import -> Playbooks that should be imported from the top level playbooks -role-* -> These playbooks call roles specifically for infrastructure tasks +role-* -> These playbooks call roles specifically for infrastructure tasks. + Playbooks that do not call a role should be named init or adhoc based + on their usage. adhoc -> These playbooks are one-off playbooks that can be used on the CLI or in AWX ``` diff --git a/ansible/init-rocky-install-kvm-hosts.yml b/ansible/init-rocky-install-kvm-hosts.yml new file mode 100644 index 0000000..c77c55d --- /dev/null +++ b/ansible/init-rocky-install-kvm-hosts.yml @@ -0,0 +1,55 @@ +--- +# Creates a standalone KVM hosts +# Created: @SherifNagy +# Modified to current standards: @nazunalika +- name: Configure KVM host + hosts: kvmhosts + become: true + + pre_tasks: + - name: Check if ansible cannot be run here + stat: + path: /etc/no-ansible + register: no_ansible + + - name: Verify if we can run ansible + assert: + that: + - "not no_ansible.stat.exists" + msg: "/etc/no-ansible exists - skipping run on this node" + + tasks: + - name: Check for CPU Virtualization + shell: "lscpu | grep -i virtualization" + register: result + failed_when: "result.rc != 0" + + # Install KVM packages + - name: Installing KVM Packages + package: + name: "{{ item }}" + state: present + with_items: + - qemu-kvm + - libvirt + - libvirt-python + - libguestfs-tools + - virt-install + + - name: Enable and Start libvirtd + systemd: + name: libvirtd + state: started + enabled: yes + + - name: Verify KVM module is loaded + shell: "lsmod | grep -i kvm" + register: result + failed_when: "result.rc != 0" + + post_tasks: + - name: Touching run file that ansible has ran here + file: + path: /var/log/ansible.run + state: touch + diff --git a/ansible/role-rocky-check-virt.yml b/ansible/role-rocky-check-virt.yml deleted file mode 100644 index 282d72b..0000000 --- a/ansible/role-rocky-check-virt.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# Check virtualization is enabled -- name: Check for CPU Virtualization - shell: "lscpu | grep -i virtualization" - register: result - failed_when: "result.rc != 0" diff --git a/ansible/role-rocky-install-kvm-hosts.yml b/ansible/role-rocky-install-kvm-hosts.yml deleted file mode 100644 index a45d1cf..0000000 --- a/ansible/role-rocky-install-kvm-hosts.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -# Install KVM packages - -- name: Installing KVM Packages - package: - name: "{{ item }}" - state: present - with_items: - - qemu-kvm - - libvirt - - libvirt-python - - libguestfs-tools - - virt-install - -- name: Enable and Start libvirtd - systemd: - name: libvirtd - state: started - enabled: yes - -- name: Verify KVM module is loaded - shell: "lsmod | grep -i kvm" - register: result - failed_when: "result.rc != 0" -