Clean up some cruft
This commit is contained in:
316
playbooks/satellite.yml
Normal file
316
playbooks/satellite.yml
Normal file
@@ -0,0 +1,316 @@
|
||||
# Playbook to install Satellite server on RHV
|
||||
|
||||
#TODO: Fix Partitioning, as /var/lib/pulp doesn't get it's own partition now.
|
||||
|
||||
- name: Preflight Setup
|
||||
hosts: "{{ vm_name }}"
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Obtain SSO token from username / password credentials
|
||||
redhat.rhv.ovirt_auth:
|
||||
url: "{{ ovirt_url }}"
|
||||
username: "{{ ovirt_username }}"
|
||||
password: "{{ ovirt_password }}"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Add host to satellite group
|
||||
add_host:
|
||||
hostname: '{{ vm_name }}'
|
||||
groups: satellite
|
||||
changed_when: false
|
||||
|
||||
- name: Get VM Tags
|
||||
ovirt.ovirt.ovirt_tag_info:
|
||||
vm: "{{ vm_name }}"
|
||||
register: vmtags_result
|
||||
delegate_to: localhost
|
||||
ignore_errors: true
|
||||
|
||||
- name: Add host to provisioned group
|
||||
add_host:
|
||||
hostname: '{{ vm_name }}'
|
||||
groups: provisioned
|
||||
when:
|
||||
- vmtags_result.ovirt_tags is defined
|
||||
- vmtags_result.ovirt_tags|length > 0
|
||||
- "'provisioned' in vmtags_result.ovirt_tags|map(attribute='name')|list"
|
||||
|
||||
- name: Build VM
|
||||
hosts: "{{ vm_name }}:!provisioned"
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: ISO is uploaded to RHV
|
||||
redhat.rhv.ovirt_disk:
|
||||
name: "{{ rhel_iso_filename }}"
|
||||
upload_image_path: "{{ rhel_iso_path }}/{{ rhel_iso_filename }}"
|
||||
storage_domain: ssdvdo0
|
||||
size: 5 GiB
|
||||
wait: true
|
||||
bootable: true
|
||||
format: raw
|
||||
content_type: iso
|
||||
register: iso_disk
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Remove known_hosts entry
|
||||
known_hosts:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ vm_name }}"
|
||||
- "{{ ansible_host }}"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Create VM disk
|
||||
ovirt_disk:
|
||||
name: "{{ vm_name }}_Disk0"
|
||||
description: '{{ vm_name }} Primary Disk'
|
||||
interface: 'virtio_scsi'
|
||||
size: '{{ disk }}GiB'
|
||||
state: attached
|
||||
sparse: yes
|
||||
wait: true
|
||||
storage_domain: "ssdvdo0"
|
||||
async: 300
|
||||
poll: 15
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Create Satellite VM in RHV
|
||||
ovirt_vm:
|
||||
name: "{{ vm_name }}"
|
||||
state: present
|
||||
memory: "{{ memory}}GiB"
|
||||
disks:
|
||||
- name: "{{ vm_name }}_Disk0"
|
||||
activate: yes
|
||||
bootable: yes
|
||||
cpu_cores: "{{ vcpus }}"
|
||||
cluster: "{{ cluster }}"
|
||||
operating_system: "rhel_7x64"
|
||||
type: server
|
||||
graphical_console:
|
||||
protocol:
|
||||
- vnc
|
||||
boot_devices:
|
||||
- hd
|
||||
async: 300
|
||||
poll: 15
|
||||
register: vm_result
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Assign NIC
|
||||
ovirt_nic:
|
||||
interface: virtio
|
||||
name: nic1
|
||||
profile: ovirtmgmt
|
||||
network: ovirtmgmt
|
||||
state: plugged
|
||||
vm: "{{ vm_name }}"
|
||||
register: nic_result
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Create directory for initial boot files
|
||||
tempfile:
|
||||
state: directory
|
||||
register: kstmpdir
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Extract ISO files
|
||||
community.general.iso_extract:
|
||||
image: "{{ rhel_iso_path }}/{{ rhel_iso_filename }}"
|
||||
dest: "{{ kstmpdir.path }}"
|
||||
files:
|
||||
- isolinux/vmlinuz
|
||||
- isolinux/initrd.img
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Generate Kickstart File
|
||||
template:
|
||||
src: templates/ks.cfg
|
||||
dest: "/var/www/ks/{{ vm_name }}.cfg"
|
||||
become: yes
|
||||
delegate_to: webserver.mgmt.toal.ca
|
||||
|
||||
- name: Temporary Directory
|
||||
file:
|
||||
path: "/tmp/{{ vm_name }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
delegate_to: "{{ vm_host }}"
|
||||
|
||||
- name: Transfer files to Hypervisor
|
||||
copy:
|
||||
src: "{{ hostvars[vm_name].kstmpdir.path }}/{{ item }}"
|
||||
dest: "/tmp/{{ vm_name }}/{{ item }}"
|
||||
loop:
|
||||
- vmlinuz
|
||||
- initrd.img
|
||||
delegate_to: "{{ vm_host }}"
|
||||
|
||||
# NOTE: This is not idempotent
|
||||
- name: First Boot
|
||||
hosts: "{{ vm_name }}:!provisioned"
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- block:
|
||||
- name: Start VM with first-boot parameters
|
||||
ovirt_vm:
|
||||
name: "{{ vm_name }}"
|
||||
host: "{{ vm_host }}"
|
||||
kernel_params_persist: false
|
||||
cd_iso: "{{ iso_disk.id }}"
|
||||
kernel_path: "/tmp/{{ vm_name }}/vmlinuz"
|
||||
kernel_params: "ks=http://192.168.1.199/ks/{{ vm_name }}.cfg inst.stage2=hd:LABEL=RHEL-7.9\\x20Server.x86_64"
|
||||
initrd_path: "/tmp/{{ vm_name }}/initrd.img"
|
||||
state: running
|
||||
delegate_to: localhost
|
||||
|
||||
|
||||
- name: Wait for system to shut down after installation
|
||||
ovirt_vm_info:
|
||||
pattern: "name={{ vm_name }}"
|
||||
register: vm_info
|
||||
until: vm_info['ovirt_vms'][0]['status'] == "down"
|
||||
delay: 20
|
||||
retries: 60
|
||||
delegate_to: localhost
|
||||
|
||||
when: hostvars[vm_name].vm_result.vm.status != 'up'
|
||||
|
||||
- name: Power up VM
|
||||
ovirt_vm:
|
||||
name: "{{ vm_name }}"
|
||||
state: running
|
||||
delegate_to: localhost
|
||||
|
||||
- name: VM is running
|
||||
ovirt_vm:
|
||||
name: "{{ vm_name }}"
|
||||
state: running
|
||||
boot_devices:
|
||||
- hd
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Set provisioned tag
|
||||
ovirt_tag:
|
||||
name: provisioned
|
||||
vms:
|
||||
- "{{ vm_name }}"
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
|
||||
- name: OS Preparation
|
||||
hosts: "{{ vm_name }}"
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
- name: Set authentication for bootstrap
|
||||
no_log: True
|
||||
set_fact:
|
||||
ansible_ssh_user: "root"
|
||||
ansible_ssh_pass: "{{ initial_root_pass }}"
|
||||
|
||||
- name: Wait for SSH to be ready
|
||||
wait_for_connection:
|
||||
timeout: 1800
|
||||
sleep: 5
|
||||
|
||||
- name: Register System to Red Hat
|
||||
redhat_subscription:
|
||||
state: present
|
||||
username: "{{ rhn_username }}"
|
||||
password: "{{ rhn_password }}"
|
||||
# TODO This shouldn't be hard-coded
|
||||
pool_ids: 8a85f99c727637ad0172e1ba2856736d
|
||||
|
||||
- name: Firewall
|
||||
firewalld:
|
||||
port: "{{ item }}"
|
||||
state: enabled
|
||||
permanent: yes
|
||||
loop:
|
||||
- "80/tcp"
|
||||
- "81/tcp"
|
||||
- "443/tcp"
|
||||
- "5647/tcp"
|
||||
- "8000/tcp"
|
||||
- "8140/tcp"
|
||||
- "9090/tcp"
|
||||
- "53/udp"
|
||||
- "53/tcp"
|
||||
- "67/udp"
|
||||
- "69/udp"
|
||||
- "5000/tcp"
|
||||
notify: Reload Firewall
|
||||
|
||||
handlers:
|
||||
- name: Reload Firewall
|
||||
service:
|
||||
name: firewalld
|
||||
state: reloaded
|
||||
|
||||
- name: Set up IPA Client
|
||||
hosts: "{{ vm_name }}"
|
||||
become: yes
|
||||
vars:
|
||||
ipaclient_realm: IDM.TOAL.CA
|
||||
ipaclient_mkhomedir: true
|
||||
ipaclient_domain: "mgmt.toal.ca"
|
||||
ipaclient_ssh_trust_dns: yes
|
||||
ipaclient_all_ip_addresses: yes
|
||||
|
||||
collections:
|
||||
- freeipa.ansible_freeipa
|
||||
pre_tasks:
|
||||
- name: Hostname is set
|
||||
hostname:
|
||||
name: "{{ vm_name }}"
|
||||
roles:
|
||||
- role: ipaclient
|
||||
state: present
|
||||
|
||||
#TODO Automatically set up DNS GSSAPI per: https://access.redhat.com/documentation/en-us/red_hat_satellite/6.8/html/installing_satellite_server_from_a_connected_network/configuring-external-services#configuring-external-idm-dns_satellite
|
||||
|
||||
- name: Set up Basic Lab Packages
|
||||
hosts: "{{ vm_name }}"
|
||||
become: yes
|
||||
roles:
|
||||
- role: toal-common
|
||||
|
||||
- name: Install Satellite Servers
|
||||
hosts: "{{ vm_name }}"
|
||||
become: true
|
||||
|
||||
roles:
|
||||
- role: jjaswanson4.install_satellite.install_satellite
|
||||
|
||||
- name: Configure Satellite Servers
|
||||
hosts: "{{ vm_name }}"
|
||||
collections:
|
||||
- jjaswanson4.configure_satellite
|
||||
|
||||
tasks:
|
||||
- name: include configure_foreman role with katello independent pieces
|
||||
include_role:
|
||||
name: configure_satellite_foreman
|
||||
- name: build satellite by organization
|
||||
include_role:
|
||||
name: configure_satellite_katello
|
||||
loop_control:
|
||||
loop_var: organization
|
||||
loop: "{{ satellite.katello }}"
|
||||
- name: do that again but for katello dependent pieces
|
||||
include_role:
|
||||
name: configure_satellite_foreman
|
||||
vars:
|
||||
requires_katello_content: true
|
||||
|
||||
# - name: Customize Satellite Installation
|
||||
# hosts: "{{ vm_name }}"
|
||||
|
||||
# collections:
|
||||
# - freeipa.ansible_freeipa
|
||||
|
||||
# tasks:
|
||||
# - name:
|
||||
Reference in New Issue
Block a user