78 lines
2.1 KiB
YAML
78 lines
2.1 KiB
YAML
---
|
|
- name: Register ec2 instance with subscription mangler
|
|
hosts: "{{ _hosts | default(omit) }}"
|
|
become: true
|
|
vars:
|
|
registration_state: present
|
|
insights_state: present
|
|
|
|
tasks:
|
|
- name: Check for org_id and activation_key
|
|
ansible.builtin.assert:
|
|
that:
|
|
- org_id is defined
|
|
- activation_key is defined
|
|
- org_id != ''
|
|
- activation_key != ''
|
|
- org_id != 'undef'
|
|
- activation_key != 'undef'
|
|
|
|
- name: Set hostname
|
|
ansible.builtin.hostname:
|
|
name: "{{ inventory_hostname | regex_replace('_', '-') }}"
|
|
|
|
# Install subscription-manager if it's not there
|
|
- name: Install subscription-manager
|
|
ansible.builtin.yum:
|
|
name: subscription-manager
|
|
state: present
|
|
|
|
- name: Remove rhui client packages
|
|
ansible.builtin.yum:
|
|
name: rh-amazon-rhui-client*
|
|
state: removed
|
|
|
|
- name: Get current repos
|
|
ansible.builtin.command:
|
|
cmd: ls /etc/yum.repos.d/
|
|
register: repos
|
|
changed_when: false
|
|
|
|
- name: Remove existing rhui repos
|
|
ansible.builtin.file:
|
|
path: "/etc/yum.repos.d/{{ item }}"
|
|
state: absent
|
|
loop: "{{ repos.stdout_lines }}"
|
|
when: "'rhui' in item"
|
|
|
|
- name: Install katello package
|
|
ansible.builtin.yum:
|
|
name: "https://{{ sat_url }}/pub/katello-ca-consumer-latest.noarch.rpm"
|
|
state: present
|
|
validate_certs: false
|
|
disable_gpg_check: true
|
|
when: sat_url is defined
|
|
|
|
- name: Manage repos with subscription mangler
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/rhsm/rhsm.conf
|
|
regexp: '^manage_repos'
|
|
line: 'manage_repos = 1'
|
|
|
|
- name: Register with subscription mangler
|
|
ansible.builtin.include_role:
|
|
name: redhat.rhel_system_roles.rhc
|
|
vars:
|
|
rhc_state: "{{ registration_state }}"
|
|
rhc_organization: "{{ org_id }}"
|
|
rhc_auth:
|
|
activation_keys:
|
|
keys:
|
|
- "{{ activation_key }}"
|
|
rhc_insights:
|
|
state: "{{ insights_state }}"
|
|
tags:
|
|
env: "{{ env }}"
|
|
purpose: demo
|
|
group: "{{ insights_tag }}"
|