Update roles
This commit is contained in:
116
roles/oatakan.rhel_ovirt_template/tasks/provision.yml
Normal file
116
roles/oatakan.rhel_ovirt_template/tasks/provision.yml
Normal file
@@ -0,0 +1,116 @@
|
||||
---
|
||||
|
||||
- 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 }}"
|
||||
Reference in New Issue
Block a user