Refactor playbook structure;Update Drone configuration
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Danny Bessems 2022-04-18 14:28:05 +02:00
parent 2f3c9fe9da
commit 6aaeee686c
5 changed files with 39 additions and 22 deletions

View File

@ -6,20 +6,18 @@ steps:
- name: Apply playbook - name: Apply playbook
image: bv11-cr01.bessems.eu/library/packer-extended image: bv11-cr01.bessems.eu/library/packer-extended
commands: commands:
- | # - |
mkdir ~/.ssh && \ # mkdir ~/.ssh && \
echo "$${private_key}" > ~/.ssh/id_rsa && \ # echo "$${private_key}" > ~/.ssh/id_rsa && \
chmod 0600 ~/.ssh/id_rsa # chmod 0600 ~/.ssh/id_rsa
- ansible-galaxy collection install -r requirements.yml - ansible-galaxy collection install -r requirements.yml
- | - |
ansible-playbook \ ansible-playbook \
# --inventory inventory.yml \ # --inventory inventory.yml \
--extra-vars "cifs_username=$${cifs_username} cifs_password=$${cifs_password}" \ --extra-vars "hv_password=$${hv_password}" \
playbook.yml playbook.yml
environment: environment:
cifs_username: hv_password:
from_secret: cifs_username from_secret: hv_password
cifs_password: # private_key:
from_secret: cifs_password # from_secret: ssh_privatekey
private_key:
from_secret: ssh_privatekey

View File

@ -1,20 +1,21 @@
- hosts: localhost - hosts: localhost
gather_facts: false gather_facts: false
vars_files: vars_files:
multiple_vms.yml - hypervisor.vcenter.yml
- nodes.yml
tasks: tasks:
- name: Clone multiple VMs from template - name: Clone multiple VMs from template
local_action: community.vmware.vmware_guest:
module: vmware_guest hostname: "{{ hv.hostname }}"
hostname: "{{ vcenter_hostname }}" username: "{{ hv.username }}"
username: "{{ username }}" password: "{{ hv_password }}"
password: "{{ password }}"
validate_certs: no validate_certs: no
folder: "{{ folder }}" datacenter: "{{ hv.datacenter }}"
template: "{{ vmtemplate }}" folder: "{{ hv.folder }}"
cluster: "{{ hv.cluster }}"
name: "{{ item.ip }}" name: "{{ item.ip }}"
cluster: "{{ vmcluster }}" template: "{{ item.template }}"
datacenter: CloudLocal
state: poweredon state: poweredon
customization_spec: "{{ customization_spec }}" # customization_spec: "{{ customization_spec }}"
delegate_to: localhost
with_items: "{{ servers }}" with_items: "{{ servers }}"

2
requirements.yml Normal file
View File

@ -0,0 +1,2 @@
collections:
- community.vmware

View File

@ -0,0 +1,8 @@
---
hv:
hostname: bv11-vc.bessems.lan
username: administrator@vsphere.local
datacenter: DeSchakel
folder: Temporary
datastore: NAS01.RAID5
network: LAN

8
vars/nodes.yml Normal file
View File

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