---
- name: Create a bastion machine
hosts: localhost
connection: local
gather_facts: false
no_log: true
roles:
- oVirt.image-template
- oVirt.vm-infra
no_log: true
vars:
engine_url: https://_Manager_FQDN_/ovirt-engine/api
engine_user: <admin@internal>
engine_password: "{{ engine_password }}"
engine_cafile: /etc/pki/ovirt-engine/ca.pem
qcow_url: <RHEL_KVM_guest_image_download_link>
template_cluster: Default
template_name: rhelguest7
template_memory: 4GiB
template_cpu: 2
wait_for_ip: true
debug_vm_create: false
vms:
- name: rhel-bastion
cluster: "{{ template_cluster }}"
profile:
cores: 2
template: "{{ template_name }}"
root_password: "{{ root_password }}"
ssh_key: "{{ lookup('file', '/root/.ssh/id_rsa_ssh_ocp_admin.pub') }}"
state: running
cloud_init:
custom_script: |
rh_subscription:
username: "{{ rhsub_user }}"
password: "{{ rhsub_pass }}"
auto-attach: true
disable-repo: ['*']
# 'rhel-7-server-rhv-4.2-manager-rpms' supports RHV 4.2 and 4.3
enable-repo: ['rhel-7-server-rpms', 'rhel-7-server-extras-rpms', 'rhel-7-server-ansible-2.7-rpms', 'rhel-7-server-ose-3.11-rpms', 'rhel-7-server-supplementary-rpms', 'rhel-7-server-rhv-4.2-manager-rpms']
packages:
- ansible
- ovirt-ansible-roles
- openshift-ansible
- python-ovirt-engine-sdk4
pre_tasks:
- name: Create an ssh key-pair for OpenShift admin
user:
name: root
generate_ssh_key: yes
ssh_key_file: .ssh/id_rsa_ssh_ocp_admin
roles:
- oVirt.image-template
- oVirt.vm-infra
- name: post installation tasks on the bastion machine
hosts: rhel-bastion
tasks:
- name: create ovirt-engine PKI dir
file:
state: directory
dest: /etc/pki/ovirt-engine/
- name: Copy the engine ca cert to the bastion machine
copy:
src: "{{ engine_cafile }}"
dest: "{{ engine_cafile }}"
- name: Copy the secured vars to the bastion machine
copy:
src: secure_vars.yaml
dest: secure_vars.yaml
decrypt: false
- file:
state: directory
path: /root/.ssh
- name: copy the OpenShift_admin keypair to the bastion machine
copy:
src: "{{ item }}"
dest: "{{ item }}"
mode: 0600
with_items:
- /root/.ssh/id_rsa_ssh_ocp_admin
- /root/.ssh/id_rsa_ssh_ocp_admin.pub
---
- name: Create a bastion machine
hosts: localhost
connection: local
gather_facts: false
no_log: true
roles:
- oVirt.image-template
- oVirt.vm-infra
no_log: true
vars:
engine_url: https://_Manager_FQDN_/ovirt-engine/api
1
engine_user: <admin@internal>
engine_password: "{{ engine_password }}"
engine_cafile: /etc/pki/ovirt-engine/ca.pem
qcow_url: <RHEL_KVM_guest_image_download_link>
2
template_cluster: Default
template_name: rhelguest7
template_memory: 4GiB
template_cpu: 2
wait_for_ip: true
debug_vm_create: false
vms:
- name: rhel-bastion
cluster: "{{ template_cluster }}"
profile:
cores: 2
template: "{{ template_name }}"
root_password: "{{ root_password }}"
ssh_key: "{{ lookup('file', '/root/.ssh/id_rsa_ssh_ocp_admin.pub') }}"
state: running
cloud_init:
custom_script: |
rh_subscription:
username: "{{ rhsub_user }}"
password: "{{ rhsub_pass }}"
auto-attach: true
disable-repo: ['*']
# 'rhel-7-server-rhv-4.2-manager-rpms' supports RHV 4.2 and 4.3
enable-repo: ['rhel-7-server-rpms', 'rhel-7-server-extras-rpms', 'rhel-7-server-ansible-2.7-rpms', 'rhel-7-server-ose-3.11-rpms', 'rhel-7-server-supplementary-rpms', 'rhel-7-server-rhv-4.2-manager-rpms']
packages:
- ansible
- ovirt-ansible-roles
- openshift-ansible
- python-ovirt-engine-sdk4
pre_tasks:
- name: Create an ssh key-pair for OpenShift admin
user:
name: root
generate_ssh_key: yes
ssh_key_file: .ssh/id_rsa_ssh_ocp_admin
roles:
- oVirt.image-template
- oVirt.vm-infra
- name: post installation tasks on the bastion machine
hosts: rhel-bastion
tasks:
- name: create ovirt-engine PKI dir
file:
state: directory
dest: /etc/pki/ovirt-engine/
- name: Copy the engine ca cert to the bastion machine
copy:
src: "{{ engine_cafile }}"
dest: "{{ engine_cafile }}"
- name: Copy the secured vars to the bastion machine
copy:
src: secure_vars.yaml
dest: secure_vars.yaml
decrypt: false
- file:
state: directory
path: /root/.ssh
- name: copy the OpenShift_admin keypair to the bastion machine
copy:
src: "{{ item }}"
dest: "{{ item }}"
mode: 0600
with_items:
- /root/.ssh/id_rsa_ssh_ocp_admin
- /root/.ssh/id_rsa_ssh_ocp_admin.pub
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow