From 6aaeee686c93bff0e1d32a43c34542ea6cbecb91 Mon Sep 17 00:00:00 2001 From: djpbessems Date: Mon, 18 Apr 2022 14:28:05 +0200 Subject: [PATCH] Refactor playbook structure;Update Drone configuration --- .drone.yml | 20 +++++++++----------- playbook.yml | 23 ++++++++++++----------- requirements.yml | 2 ++ vars/hypervisor.vcenter.yml | 8 ++++++++ vars/nodes.yml | 8 ++++++++ 5 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 requirements.yml create mode 100644 vars/hypervisor.vcenter.yml create mode 100644 vars/nodes.yml diff --git a/.drone.yml b/.drone.yml index 769b85b..72e4f7c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,20 +6,18 @@ steps: - name: Apply playbook image: bv11-cr01.bessems.eu/library/packer-extended commands: - - | - mkdir ~/.ssh && \ - echo "$${private_key}" > ~/.ssh/id_rsa && \ - chmod 0600 ~/.ssh/id_rsa + # - | + # mkdir ~/.ssh && \ + # echo "$${private_key}" > ~/.ssh/id_rsa && \ + # chmod 0600 ~/.ssh/id_rsa - ansible-galaxy collection install -r requirements.yml - | ansible-playbook \ # --inventory inventory.yml \ - --extra-vars "cifs_username=$${cifs_username} cifs_password=$${cifs_password}" \ + --extra-vars "hv_password=$${hv_password}" \ playbook.yml environment: - cifs_username: - from_secret: cifs_username - cifs_password: - from_secret: cifs_password - private_key: - from_secret: ssh_privatekey + hv_password: + from_secret: hv_password + # private_key: + # from_secret: ssh_privatekey diff --git a/playbook.yml b/playbook.yml index bfa7d7c..24d6e94 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,20 +1,21 @@ - hosts: localhost gather_facts: false vars_files: - multiple_vms.yml + - hypervisor.vcenter.yml + - nodes.yml tasks: - name: Clone multiple VMs from template - local_action: - module: vmware_guest - hostname: "{{ vcenter_hostname }}" - username: "{{ username }}" - password: "{{ password }}" + community.vmware.vmware_guest: + hostname: "{{ hv.hostname }}" + username: "{{ hv.username }}" + password: "{{ hv_password }}" validate_certs: no - folder: "{{ folder }}" - template: "{{ vmtemplate }}" + datacenter: "{{ hv.datacenter }}" + folder: "{{ hv.folder }}" + cluster: "{{ hv.cluster }}" name: "{{ item.ip }}" - cluster: "{{ vmcluster }}" - datacenter: CloudLocal + template: "{{ item.template }}" state: poweredon - customization_spec: "{{ customization_spec }}" + # customization_spec: "{{ customization_spec }}" + delegate_to: localhost with_items: "{{ servers }}" diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..15152ee --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ +collections: +- community.vmware \ No newline at end of file diff --git a/vars/hypervisor.vcenter.yml b/vars/hypervisor.vcenter.yml new file mode 100644 index 0000000..a526b03 --- /dev/null +++ b/vars/hypervisor.vcenter.yml @@ -0,0 +1,8 @@ +--- +hv: + hostname: bv11-vc.bessems.lan + username: administrator@vsphere.local + datacenter: DeSchakel + folder: Temporary + datastore: NAS01.RAID5 + network: LAN diff --git a/vars/nodes.yml b/vars/nodes.yml new file mode 100644 index 0000000..9fb8f67 --- /dev/null +++ b/vars/nodes.yml @@ -0,0 +1,8 @@ +--- +servers: + - ip: 192.168.11.121 + template: xyz + - ip: 192.168.11.122 + template: abc + - ip: 192.168.11.123 + template: pqr