Update role dependencies

This commit is contained in:
2024-02-08 15:55:01 -05:00
parent e09a7f7d45
commit bb21e8d5c6
507 changed files with 1270 additions and 28219 deletions

View File

@@ -39,12 +39,13 @@ Example Playbook
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
---
# import ovirt.ovirt collections
- name: create a ovirt rhel template
hosts: all
gather_facts: False
gather_facts: false
connection: local
become: no
become: false
vars:
template_force: yes #overwrite existing template with the same name
export_ovf: no # export the template to export domain upon creation
@@ -75,6 +76,18 @@ Including an example of how to use your role (for instance, with variables passe
roles:
- oatakan.rhel_ovirt_template
---
# import ovirt.ovirt collections
- name: delete a ovirt rhel template
hosts: all
gather_facts: false
connection: local
become: false
roles:
- role: oatakan.rhel_ovirt_template
role_action: deprovision
License
-------

View File

@@ -1,12 +1,14 @@
---
role_action: provision #provision or deprovision
install_updates: yes
instance_wait_retry_limit: 300
instance_wait_connection_timeout: 600
# this will remove existing template with the same name
template_force: no
template_found: no
template_force: false
template_found: false
export_ovf: no
@@ -22,13 +24,13 @@ qemu_second_cdrom_device_bus_type: ide
qemu_second_cdrom_device_bus_id: 3
qemu_second_cdrom_device_bus_unit: 0
local_administrator_password: Chang3MyP@ssw0rd21
local_administrator_password: ''
local_account_username: ansible
local_account_password: Chang3MyP@ssw0rd21
local_account_password: ''
distro_name: rhel8
iso_file_name: CentOS-8.4.2105-x86_64-dvd1.iso
linux_ks_folder: rhel8
distro_name: rhel9
iso_file_name: CentOS-Stream-9-latest-x86_64-dvd1.iso
linux_ks_folder: rhel9
template_vm_name: centos84-x64-v1
template_vm_root_disk_size: 10
@@ -36,7 +38,7 @@ template_vm_root_disk_format: cow
template_vm_root_disk_interface: virtio
template_vm_memory: 4096
template_vm_cpu: 2
template_vm_guest_id: rhel_7x64
template_vm_guest_id: rhel_8x64
template_vm_efi: no
template_vm_network_name: ovirtmgmt
template_vm_ip_address: 192.168.10.96
@@ -51,6 +53,8 @@ template_convert_timeout: 600
template_convert_seal: no
template_selinux_enabled: no
permit_root_login_with_password: true
ovirt_datacenter: mydatacenter
ovirt_cluster: production
ovirt_folder: template
@@ -64,4 +68,7 @@ os_short_names:
guest_id: rhel_7x64
rhel8:
ks_folder: rhel8
guest_id: rhel_8x64
rhel9:
ks_folder: rhel9
guest_id: rhel_8x64

View File

@@ -1,2 +1,2 @@
install_date: Fri Oct 15 18:59:21 2021
install_date: Thu 08 Feb 2024 08:54:05 PM
version: master

View File

@@ -19,120 +19,8 @@
- include_tasks: remove_template.yml
when:
- template_force|bool
- remove_template
- template_found|bool
- block:
- include_tasks: make_iso.yml
- include_tasks: provision_vm.yml
- name: refresh inventory
meta: refresh_inventory
- name: clear gathered facts
meta: clear_facts
- name: clear any host errors
meta: clear_host_errors
- name: add host
add_host:
hostname: template_vm
ansible_host: '{{ template_vm_ip_address }}'
host_key_checking: false
ansible_user: "{{ local_account_username }}"
ansible_password: "{{ local_account_password }}"
ansible_port: "{{ vm_ansible_port | default('22') }}"
ansible_ssh_common_args: '-o UserKnownHostsFile=/dev/null'
ansible_python_interpreter: auto
- name: run setup module
setup:
delegate_to: template_vm
connection: ssh
- block:
- include_role:
name: oatakan.rhn
apply:
delegate_to: template_vm
connection: ssh
become: yes
- include_role:
name: oatakan.rhel_upgrade
apply:
delegate_to: template_vm
connection: ssh
become: yes
when: install_updates|bool
- include_role:
name: oatakan.rhel_template_build
apply:
delegate_to: template_vm
connection: ssh
become: yes
vars:
target_ovirt: yes
always:
- include_role:
name: oatakan.rhn
apply:
delegate_to: template_vm
connection: ssh
become: yes
vars:
role_action: unregister
- name: force handlers to run before stoppping the vm
meta: flush_handlers
- name: refresh SSO credentials
ovirt.ovirt.ovirt_auth:
url: "{{ lookup('env', 'OVIRT_URL')|default(ovirt.url, true) }}"
username: "{{ lookup('env', 'OVIRT_USERNAME')|default(ovirt.username, true) }}"
password: "{{ lookup('env', 'OVIRT_PASSWORD')|default(ovirt.password, true) }}"
insecure: yes
- include_tasks: stop_vm.yml
- include_tasks: convert_to_template.yml
- include_tasks: export_ovf.yml
when: export_ovf|bool
rescue:
- name: refresh SSO credentials
ovirt.ovirt.ovirt_auth:
url: "{{ lookup('env', 'OVIRT_URL')|default(ovirt.url, true) }}"
username: "{{ lookup('env', 'OVIRT_USERNAME')|default(ovirt.username, true) }}"
password: "{{ lookup('env', 'OVIRT_PASSWORD')|default(ovirt.password, true) }}"
insecure: yes
- include_tasks: remove_template.yml
when: remove_vm_on_error|bool
always:
- name: refresh SSO credentials
ovirt.ovirt.ovirt_auth:
url: "{{ lookup('env', 'OVIRT_URL')|default(ovirt.url, true) }}"
username: "{{ lookup('env', 'OVIRT_USERNAME')|default(ovirt.username, true) }}"
password: "{{ lookup('env', 'OVIRT_PASSWORD')|default(ovirt.password, true) }}"
insecure: yes
- include_tasks: remove_vm.yml
- include_tasks: datastore_iso_remove.yml
- name: remove temporary directory
file:
path: "{{ temp_directory }}"
state: absent
- name: logout from oVirt
ovirt.ovirt.ovirt_auth:
state: absent
ovirt_auth: "{{ ovirt_auth }}"
- include_tasks: provision.yml
when: role_action == 'provision'

View File

@@ -1,5 +1,9 @@
---
- name: set template_found to false
set_fact:
template_found: false
- name: get the datacenter name
ovirt.ovirt.ovirt_datacenter_info:
auth: "{{ ovirt_auth }}"
@@ -35,36 +39,38 @@
register: template_info
- block:
- name: set template_found to yes
- name: set template_found to true
set_fact:
template_found: yes
template_found: true
- name: fail with message
fail:
msg: "Existing template found on ovirt/rhv: {{ template.name }}"
when: not template_force|bool
when: not remove_template
when:
- template_info.ovirt_templates is defined
- template_info.ovirt_templates | length > 0
- name: check iso file on data domain
ovirt.ovirt.ovirt_disk_info:
auth: "{{ ovirt_auth }}"
pattern: "name={{ iso_file_name }}"
register: ovirt_disk_main_iso
when: iso_file_name is defined
- block:
- name: check iso file on data domain
ovirt.ovirt.ovirt_disk_info:
auth: "{{ ovirt_auth }}"
pattern: "name={{ iso_file_name }}"
register: ovirt_disk_main_iso
when: iso_file_name is defined
- name: set file id of the iso file
set_fact:
iso_file_id: "{{ ovirt_disk_main_iso.ovirt_disks[0].id }}"
when:
- ovirt_disk_main_iso.ovirt_disks | length > 0
- ovirt_disk_main_iso.ovirt_disks[0].id is defined
- ovirt_disk_main_iso.ovirt_disks[0].content_type == 'iso'
- name: set file id of the iso file
set_fact:
iso_file_id: "{{ ovirt_disk_main_iso.ovirt_disks[0].id }}"
when:
- ovirt_disk_main_iso.ovirt_disks | length > 0
- ovirt_disk_main_iso.ovirt_disks[0].id is defined
- ovirt_disk_main_iso.ovirt_disks[0].content_type == 'iso'
- name: fail with message
fail:
msg: "iso file ({{ iso_file_name }}) could not be found on the data domain and iso domain does not exists"
when:
- iso_file_id is undefined
- iso_domain is undefined or iso_domain|length == 0
- name: fail with message
fail:
msg: "iso file ({{ iso_file_name }}) could not be found on the data domain and iso domain does not exists"
when:
- iso_file_id is undefined
- iso_domain is undefined or iso_domain|length == 0
when: role_action == 'provision'

View File

@@ -1,5 +1,9 @@
---
- name: set template_found to false
set_fact:
template_found: false
- name: get the datacenter name (<2.9)
ovirt_datacenter_facts:
auth: "{{ ovirt_auth }}"
@@ -33,35 +37,37 @@
- block:
- name: set template_found to yes
- name: set template_found to true
set_fact:
template_found: yes
template_found: true
- name: fail with message
fail:
msg: "Existing template found on ovirt/rhv: {{ template.name }}"
when: not template_force|bool
when: not remove_template
when:
- ovirt_templates is defined
- ovirt_templates | length > 0
- name: check iso file on data domain
ovirt_disk_facts:
auth: "{{ ovirt_auth }}"
pattern: "name={{ iso_file_name }}"
when: iso_file_name is defined
- block:
- name: check iso file on data domain
ovirt_disk_facts:
auth: "{{ ovirt_auth }}"
pattern: "name={{ iso_file_name }}"
when: iso_file_name is defined
- name: set file id of the iso file
set_fact:
iso_file_id: "{{ ovirt_disks[0].id }}"
when:
- ovirt_disks | length > 0
- ovirt_disks[0].id is defined
- ovirt_disks[0].content_type == 'iso'
- name: set file id of the iso file
set_fact:
iso_file_id: "{{ ovirt_disks[0].id }}"
when:
- ovirt_disks | length > 0
- ovirt_disks[0].id is defined
- ovirt_disks[0].content_type == 'iso'
- name: fail with message
fail:
msg: "iso file ({{ template.name }}) could not be found on the data domain and iso domain does not exists"
when:
- iso_file_id is undefined
- iso_domain is undefined or iso_domain|length == 0
- name: fail with message
fail:
msg: "iso file ({{ template.name }}) could not be found on the data domain and iso domain does not exists"
when:
- iso_file_id is undefined
- iso_domain is undefined or iso_domain|length == 0
when: role_action == 'provision'

View File

@@ -13,7 +13,7 @@ network --bootproto=dhcp
network --hostname=localhost.localdomain
rootpw {{ local_administrator_password }}
authconfig --enableshadow --passalgo=sha512
authselect --enableshadow --passalgo=sha512
{% if template_selinux_enabled is undefined or not template_selinux_enabled %}
selinux --disabled

View File

@@ -6,6 +6,8 @@ iso_file: "linux_{{ distro_name }}_ks{{ awx_job_id | default('') }}.iso"
export_dir: "{{ playbook_dir }}/{{ temp_directory }}"
remove_template: "{{ true if (role_action == 'deprovision' or template_force|bool) else false }}"
providers:
ovirt:
datacenter: "{{ ovirt_datacenter }}"
@@ -39,8 +41,8 @@ template:
dns_servers: "{{ template_vm_dns_servers }}"
cd_iso: "{{ iso_file_id | default(iso_file_name) }}" # if using data domain, file name does not work, need to use id
linux_ks_folder: "{{ os_short_names[(distro_name|default('rhel_80'))].ks_folder | default('rhel8') }}"
template_vm_guest_id: "{{ os_short_names[(distro_name|default('rhel_80'))].guest_id | default('rhel_8x64') }}"
linux_ks_folder: "{{ os_short_names[(distro_name|default('rhel8'))].ks_folder | default('rhel8') }}"
template_vm_guest_id: "{{ os_short_names[(distro_name|default('rhel8'))].guest_id | default('rhel_8x64') }}"
qemu_cmdline_second_iso:
- -device