diff --git a/breakfix1/README.md b/SCENARIO_LEAPP/README.md similarity index 52% rename from breakfix1/README.md rename to SCENARIO_LEAPP/README.md index d879988..dff56eb 100644 --- a/breakfix1/README.md +++ b/SCENARIO_LEAPP/README.md @@ -1,23 +1,16 @@ -breakfix1 +breakfix0/SCENARIO_LEAPP ========= -This role targets to break a satellite and capsule server in a way that, neither hosts will be able to download patches from them nor any repos can be successully resynced on the satellite. - -Example Error: - -Status code: 500 when trying to install\update packages on the RHEL systems connected with the satellite server through a capsule server. - -~~~ -[MIRROR] katello-host-tools-4.2.3-5.el8sat.noarch.rpm: Status code: 500 for https://capsule.example.com/pulp/content/RedHat/Library/content/dist/layered/rhel8/x86_64/sat-client/6/os/Packages/k/katello-host-tools-4.2.3-5.el8sat.noarch.rpm (IP: XX.XX.XXX.XXX) -~~~ +This role registers a RHEL8 client to satellite and simulates few problems while performing the LEAPP upgrade to RHEL9. What we essentially do by this ansible role is: * Confirm that the satellite is running * Create an activation key -* Generate a registration command [ via Global registration method ] to register a host through the external capsule server +* Create and publish content view without the RHEL9 minor repos +* Generate a registration command [ via Global registration method ] to register the client to satellite * Execute the command on the client and register it -* Update database records of satellite and capsule to break them. +* Configure EPEL on client and install openssl rpms from it. Requirements @@ -41,12 +34,12 @@ Example Playbook This ansible role can be executed after creating a playbook in the following way. ~~~ -# cat breakfix1.yaml +# cat breakfix0.yaml --- -- name: Deploy ansible role breakfix1 on target systems +- name: Deploy ansible role breakfix0 on target systems hosts: satellite roles: - - role: breakfix1 + - role: breakfix0 tags: break ~~~ @@ -58,4 +51,4 @@ It is free software licensed under the terms of the GNU General Public License G Author Information ------------------ -This role is developed by Sayan Das , . +This role is developed by Soham Majumdar , . diff --git a/SCENARIO_LEAPP/breakfix0.yml b/SCENARIO_LEAPP/breakfix0.yml new file mode 100644 index 0000000..837610e --- /dev/null +++ b/SCENARIO_LEAPP/breakfix0.yml @@ -0,0 +1,6 @@ +--- +- name: Deploy ansible role breakfix1 on target systems + hosts: satellite + roles: + - role: breakfix0 + tags: break diff --git a/SCENARIO_LEAPP/breakfix0/tasks/main.yml b/SCENARIO_LEAPP/breakfix0/tasks/main.yml new file mode 100644 index 0000000..252d283 --- /dev/null +++ b/SCENARIO_LEAPP/breakfix0/tasks/main.yml @@ -0,0 +1,105 @@ +--- +# tasks file for breakfix0 +- name: Set initial facts + ansible.builtin.set_fact: + satellite_hostname: "{{ ansible_fqdn }}" + +- name: Read credentials + ansible.builtin.slurp: + path: /root/.hammer/cli.modules.d/foreman.yml + register: slurp + +- name: Set credentials + set_fact: + password: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':password'] }}" + username: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':username'] }}" + + +- name: Ensure satellite is running. + theforeman.foreman.status_info: + server_url: "https://{{ satellite_hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: false + register: status_info + +- name: "Create or update leapp content view" + theforeman.foreman.content_view: + username: "{{ username }}" + password: "{{ password }}" + server_url: "https://{{ satellite_hostname }}" + name: "leapp_8to9" + organization: "{{ satellite_organization }}" + repositories: + - name: 'Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs 9' + product: 'Red Hat Enterprise Linux for x86_64' + - name: 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs 9' + product: 'Red Hat Enterprise Linux for x86_64' + - name: 'Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8' + product: 'Red Hat Enterprise Linux for x86_64' + - name: 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8' + product: 'Red Hat Enterprise Linux for x86_64' + +- name: "Publish the leapp content view" + theforeman.foreman.content_view_version: + username: "{{ username }}" + password: "{{ password }}" + server_url: "https://{{ satellite_hostname }}" + content_view: "leapp_8to9" + organization: "{{ satellite_organization }}" + + +- name: Create client activation key + theforeman.foreman.activation_key: + server_url: "https://{{ satellite_hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: false + name: "{{ activation_key }}" + organization: "{{ satellite_organization }}" + lifecycle_environment: "Library" + content_view: "leapp_8to9" + when: status_info['status']['result'] == "ok" + register: ak_created + +- name: Create EPEL repo on client + ansible.builtin.yum_repository: + name: epel + description: EPEL YUM repo + baseurl: https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/ + gpgcheck: no + delegate_to: "{{ groups['client'][0] }}" + +- name: Install openssl3 + ansible.builtin.dnf: + name: openssl3 + state: present + delegate_to: "{{ groups['client'][0] }}" + + + + +- name: Generate registration command to register the system with Satellite server + theforeman.foreman.registration_command: + server_url: "https://{{ satellite_hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: false + setup_remote_execution: true + setup_insights: false + jwt_expiration: 8 + force: true + insecure: true + activation_keys: "{{ activation_key }}" + organization: "{{ satellite_organization }}" + location: "{{ satellite_location }}" +# smart_proxy: "{{ groups['capsule'][0] }}" + when: ak_created is success + register: global_reg_command + +- name: Regsiter the client host + ansible.builtin.command: bash -c "{{ global_reg_command['registration_command'] }}" + delegate_to: "{{ groups['client'][0] }}" + register: host_registration + when: global_reg_command is defined + diff --git a/SCENARIO_LEAPP/breakfix0/vars/main.yml b/SCENARIO_LEAPP/breakfix0/vars/main.yml new file mode 100644 index 0000000..619f8ed --- /dev/null +++ b/SCENARIO_LEAPP/breakfix0/vars/main.yml @@ -0,0 +1,5 @@ +--- +# vars file for breakfix1 +satellite_organization: "Default Organization" +satellite_location: "Default Location" +activation_key: "RHEL-AK" diff --git a/SCENARIO_LEAPP/grade.yml b/SCENARIO_LEAPP/grade.yml new file mode 100644 index 0000000..fa200ee --- /dev/null +++ b/SCENARIO_LEAPP/grade.yml @@ -0,0 +1,13 @@ +--- +- name: Grading playbook for SCENARIO_LEAPP + hosts: rhel81 + tasks: + - name: Detecting result + ansible.builtin.debug: + msg: "Success. your alphanumeric code for completion is RHEL9" + when: ansible_facts['distribution_major_version'] == "9" + + - name: In case of failure + ansible.builtin.debug: + msg: "The system is not upgraded successfully yet, please try again." + when: ansible_facts['distribution_major_version'] != "9" diff --git a/SCENARIO_LEAPP/requirements.yml b/SCENARIO_LEAPP/requirements.yml new file mode 100644 index 0000000..119e606 --- /dev/null +++ b/SCENARIO_LEAPP/requirements.yml @@ -0,0 +1,7 @@ +--- +collections: + - name: https://github.com/theforeman/foreman-ansible-modules.git + type: git + version: develop + - name: ansible.posix + - name: community.general diff --git a/SCENARIO_PERFORMANCE/README.md b/SCENARIO_PERFORMANCE/README.md new file mode 100644 index 0000000..f0232b3 --- /dev/null +++ b/SCENARIO_PERFORMANCE/README.md @@ -0,0 +1,50 @@ +breakfix2/SCENARIO_PERFORMANCE +========= + +This role breaks the satellite by setting some large values to few of the satellite params. + +What we essentially do by this ansible role is: + +* Confirm that the satellite is running +* Set large values to puma max min threads, puma workers, foreman db pool, pulpcore workers + + +Requirements +------------ + +This ansible role requires the [foreman ansible modules](https://github.com/theforeman/foreman-ansible-modules/). Please install them before executing the role. + +Role Variables +-------------- + +The `vars/main.yml` file contains the required variables for the ansible role. Adjust the values according to your environment. + +Dependencies +------------ + +NA + +Example Playbook +---------------- + +This ansible role can be executed after creating a playbook in the following way. + +~~~ +# cat breakfix2.yaml +--- +- name: Deploy ansible role breakfix2 on target systems + hosts: satellite + roles: + - role: breakfix2 + tags: break +~~~ + +License +------- + +It is free software licensed under the terms of the GNU General Public License GPL v3 or later. A copy of the license can be obtained here: http://www.gnu.org/licenses/gpl-3.0.html + +Author Information +------------------ + +This role is developed by Soham Majumdar , . diff --git a/SCENARIO_PERFORMANCE/breakfix2.yml b/SCENARIO_PERFORMANCE/breakfix2.yml new file mode 100644 index 0000000..ccdf9c1 --- /dev/null +++ b/SCENARIO_PERFORMANCE/breakfix2.yml @@ -0,0 +1,7 @@ +--- +- name: Deploy ansible role breakfix1 on target systems + hosts: satellite + roles: + - role: breakfix2 + tags: break + diff --git a/SCENARIO_PERFORMANCE/breakfix2/tasks/main.yml b/SCENARIO_PERFORMANCE/breakfix2/tasks/main.yml new file mode 100644 index 0000000..3a05245 --- /dev/null +++ b/SCENARIO_PERFORMANCE/breakfix2/tasks/main.yml @@ -0,0 +1,45 @@ +--- +# tasks file for breakfix2 +- name: Set initial facts + ansible.builtin.set_fact: + satellite_hostname: "{{ ansible_fqdn }}" + +- name: Read credentials + slurp: + path: /root/.hammer/cli.modules.d/foreman.yml + register: slurp + +- name: Set credentials + set_fact: + password: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':password'] }}" + username: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':username'] }}" + + +- name: Ensure satellite is running. + theforeman.foreman.status_info: + server_url: "https://{{ satellite_hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: false + register: status_info + +- name: Breaking foreman_service_puma_threads_min + shell: "sed -i 's/foreman_service_puma_threads_min:/foreman_service_puma_threads_min: 300/' /etc/foreman-installer/scenarios.d/satellite-answers.yaml" +- name: Breaking foreman_service_puma_threads_max + shell: "sed -i 's/foreman_service_puma_threads_max: 5/foreman_service_puma_threads_max: 300/' /etc/foreman-installer/scenarios.d/satellite-answers.yaml" +- name: Breaking s/foreman_service_puma_workers + shell: "sed -i 's/foreman_service_puma_workers:/foreman_service_puma_workers: 120/' /etc/foreman-installer/scenarios.d/satellite-answers.yaml" +- name: Breaking db_pool + shell: "sed -i 's/db_pool:/db_pool: 300/' /etc/foreman-installer/scenarios.d/satellite-answers.yaml" +- name: Breaking pulpcore_worker_count + shell: "sed -i 's/pulpcore_worker_count: 8/pulpcore_worker_count: 10/' /etc/foreman-installer/scenarios.d/satellite-answers.yaml" + +- name: Fair Warning + debug: + msg: The next task will probably run for 8-10 mins and may end in error. But its expected. + +- name: Breaking satellite + shell: "satellite-installer" + ignore_errors: true + + diff --git a/SCENARIO_PERFORMANCE/breakfix2/vars/main.yml b/SCENARIO_PERFORMANCE/breakfix2/vars/main.yml new file mode 100644 index 0000000..1ffcf73 --- /dev/null +++ b/SCENARIO_PERFORMANCE/breakfix2/vars/main.yml @@ -0,0 +1,6 @@ +--- +# vars file for breakfix1 +satellite_organization: "Default Organization" +satellite_location: "Default Location" +activation_key: "RHEL-AK" + diff --git a/SCENARIO_PERFORMANCE/grade.yml b/SCENARIO_PERFORMANCE/grade.yml new file mode 100644 index 0000000..285bcf8 --- /dev/null +++ b/SCENARIO_PERFORMANCE/grade.yml @@ -0,0 +1,46 @@ +--- +- name: Grading playbook for SCENARIO_PERFORMANCE + hosts: satellite + gather_facts: yes + tasks: + - name: Reading answers file using slurp + slurp: + path: /etc/foreman-installer/scenarios.d/satellite-answers.yaml + register: answers_file + + - name: Extracting puma_thread_max_min puma_worker db_pool pulp_worker + set_fact: + puma_thread_max: "{{ (answers_file.content | b64decode | from_yaml)['foreman']['foreman_service_puma_threads_max'] }}" + puma_thread_min: "{{ (answers_file.content | b64decode | from_yaml)['foreman']['foreman_service_puma_threads_min'] }}" + puma_worker: "{{ (answers_file.content | b64decode | from_yaml)['foreman']['foreman_service_puma_workers'] }}" + db_pool: "{{ (answers_file.content | b64decode | from_yaml)['foreman']['db_pool'] }}" + pulp_worker: "{{ (answers_file.content | b64decode | from_yaml)['foreman_proxy_content']['pulpcore_worker_count'] }}" + + - name: Reading last_scenario + slurp: + path: /etc/foreman-installer/scenarios.d/last_scenario.yaml + register: last_scenario + + - name: Extracting tuning_profile + set_fact: + tuning_profile: "{{ (last_scenario.content | b64decode | from_yaml)[':facts']['tuning'] }}" + + - name: Displaying what is being captured + debug: + msg: puma_thread_max is "{{ puma_thread_max }}" | puma_thread_min is "{{ puma_thread_min }}" | puma_worker is "{{ puma_worker }}" | db_pool is "{{ db_pool }}" | pulp_worker is "{{ pulp_worker }}" | tuning_profile is "{{ tuning_profile }}" + + - name: Checking result + ansible.builtin.debug: + msg: Success. your alphanumeric code for completion is PERFORMANCE + when: + - puma_thread_max == "16" + - puma_thread_min == "16" + - ( puma_worker | float >= 8 and puma_worker | float <= 12 ) + - db_pool == "16" + - pulp_worker == "8" + - tuning_profile == "medium" + + - name: In case of failure + ansible.builtin.debug: + msg: "The satellite is not tuned correctly, please try again." + when: db_pool != "16" or tuning_profile != "medium" or puma_thread_max != "16" or puma_thread_min != "16" or pulp_worker != "8" or ( puma_worker | float != 12 and puma_worker | float != 11 and puma_worker | float != 10 and puma_worker | float != 9 and puma_worker | float != 8 ) diff --git a/SCENARIO_PERFORMANCE/requirements.yml b/SCENARIO_PERFORMANCE/requirements.yml new file mode 100644 index 0000000..119e606 --- /dev/null +++ b/SCENARIO_PERFORMANCE/requirements.yml @@ -0,0 +1,7 @@ +--- +collections: + - name: https://github.com/theforeman/foreman-ansible-modules.git + type: git + version: develop + - name: ansible.posix + - name: community.general diff --git a/SCENARIO_TFTP_ANSWERSFILE/README.md b/SCENARIO_TFTP_ANSWERSFILE/README.md new file mode 100644 index 0000000..4a8c5f6 --- /dev/null +++ b/SCENARIO_TFTP_ANSWERSFILE/README.md @@ -0,0 +1,52 @@ +breakfix3/SCENARIO_TFTP +========= + +This role breaks the satellite by adding incorrect param for tftp_dirs in satellite answers file. + +What we essentially do by this ansible role is: + +* Confirm that the satellite is running +* Enable tftp on satellite +* Add an incorrect param for tftp_dirs. +* Run satellite-installer + + +Requirements +------------ + +This ansible role requires the [foreman ansible modules](https://github.com/theforeman/foreman-ansible-modules/). Please install them before executing the role. + +Role Variables +-------------- + +The `vars/main.yml` file contains the required variables for the ansible role. Adjust the values according to your environment. + +Dependencies +------------ + +NA + +Example Playbook +---------------- + +This ansible role can be executed after creating a playbook in the following way. + +~~~ +# cat breakfix3.yaml +--- +- name: Deploy ansible role breakfix3 on target systems + hosts: satellite + roles: + - role: breakfix3 + tags: break +~~~ + +License +------- + +It is free software licensed under the terms of the GNU General Public License GPL v3 or later. A copy of the license can be obtained here: http://www.gnu.org/licenses/gpl-3.0.html + +Author Information +------------------ + +This role is developed by Soham Majumdar , . diff --git a/SCENARIO_TFTP_ANSWERSFILE/breakfix3.yml b/SCENARIO_TFTP_ANSWERSFILE/breakfix3.yml new file mode 100644 index 0000000..7681009 --- /dev/null +++ b/SCENARIO_TFTP_ANSWERSFILE/breakfix3.yml @@ -0,0 +1,7 @@ +--- +- name: Deploy ansible role breakfix1 on target systems + hosts: satellite + roles: + - role: breakfix3 + tags: break + diff --git a/SCENARIO_TFTP_ANSWERSFILE/breakfix3/tasks/main.yml b/SCENARIO_TFTP_ANSWERSFILE/breakfix3/tasks/main.yml new file mode 100644 index 0000000..399a3fc --- /dev/null +++ b/SCENARIO_TFTP_ANSWERSFILE/breakfix3/tasks/main.yml @@ -0,0 +1,34 @@ +--- +# tasks file for breakfix3 +- name: Set initial facts + ansible.builtin.set_fact: + satellite_hostname: "{{ ansible_fqdn }}" + +- name: Read credentials + slurp: + path: /root/.hammer/cli.modules.d/foreman.yml + register: slurp + +- name: Set credentials + set_fact: + password: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':password'] }}" + username: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':username'] }}" + + +- name: Ensure satellite is running. + theforeman.foreman.status_info: + server_url: "https://{{ satellite_hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: false + register: status_info + +- name: Enabling TFTP + shell: "satellite-installer --foreman-proxy-tftp true --foreman-proxy-tftp-managed true --foreman-proxy-tftp-servername $(hostname -f)" + +- name: Breaking answers file + shell: sed -i '240i \ \ - "/var/lib/tftpboot/pxelinux.cfg,/var/lib/tftpboot/grub,/var/lib/tftpboot/grub2,/var/lib/tftpboot/boot,/var/lib/tftpboot/ztp.cfg,/var/lib/tftpboot/poap.cfg"' /etc/foreman-installer/scenarios.d/satellite-answers.yaml + +- name: Breaking satellite and this task will end in error. + shell: "satellite-installer" + ignore_errors: yes diff --git a/SCENARIO_TFTP_ANSWERSFILE/breakfix3/vars/main.yml b/SCENARIO_TFTP_ANSWERSFILE/breakfix3/vars/main.yml new file mode 100644 index 0000000..1ffcf73 --- /dev/null +++ b/SCENARIO_TFTP_ANSWERSFILE/breakfix3/vars/main.yml @@ -0,0 +1,6 @@ +--- +# vars file for breakfix1 +satellite_organization: "Default Organization" +satellite_location: "Default Location" +activation_key: "RHEL-AK" + diff --git a/SCENARIO_TFTP_ANSWERSFILE/grade.yml b/SCENARIO_TFTP_ANSWERSFILE/grade.yml new file mode 100644 index 0000000..01f52b4 --- /dev/null +++ b/SCENARIO_TFTP_ANSWERSFILE/grade.yml @@ -0,0 +1,28 @@ +--- +- name: Grading playbook for SCENARIO_TFTP_ANSWERSFILE + hosts: satellite + gather_facts: yes + tasks: + - name: Reading answers file using slurp + slurp: + path: /etc/foreman-installer/scenarios.d/satellite-answers.yaml + register: answers_file + + - name: Extracting tftp_directories + set_fact: + tftp_directories: "{{ (answers_file.content | b64decode | from_yaml)['foreman_proxy']['tftp_dirs'] }}" + + - name: Displaying what is being captured + debug: + msg: tftp_directories is "{{ tftp_directories }}" + + - name: Checking result + ansible.builtin.debug: + msg: Success. your alphanumeric code for completion is TFTP615 + when: + - tftp_directories == ['/var/lib/tftpboot/pxelinux.cfg','/var/lib/tftpboot/grub','/var/lib/tftpboot/grub2','/var/lib/tftpboot/boot','/var/lib/tftpboot/ztp.cfg','/var/lib/tftpboot/poap.cfg'] + - name: In case of failure + ansible.builtin.debug: + msg: TFTP dirs are not configured correctly, please try again. + when: + - tftp_directories != ['/var/lib/tftpboot/pxelinux.cfg','/var/lib/tftpboot/grub','/var/lib/tftpboot/grub2','/var/lib/tftpboot/boot','/var/lib/tftpboot/ztp.cfg','/var/lib/tftpboot/poap.cfg'] diff --git a/SCENARIO_TFTP_ANSWERSFILE/requirements.yml b/SCENARIO_TFTP_ANSWERSFILE/requirements.yml new file mode 100644 index 0000000..119e606 --- /dev/null +++ b/SCENARIO_TFTP_ANSWERSFILE/requirements.yml @@ -0,0 +1,7 @@ +--- +collections: + - name: https://github.com/theforeman/foreman-ansible-modules.git + type: git + version: develop + - name: ansible.posix + - name: community.general diff --git a/SCENARIO_UPGRADE_INSTALLER/README.md b/SCENARIO_UPGRADE_INSTALLER/README.md new file mode 100644 index 0000000..766f329 --- /dev/null +++ b/SCENARIO_UPGRADE_INSTALLER/README.md @@ -0,0 +1,53 @@ +breakfix1/SCENARIO_UPGRADE +========= + +This role simulates some problems while doing a satellite upgrade. + +What we essentially do by this ansible role is: + +* Confirm that the satellite is running +* Change the IP in /etc/hosts +* Replace hostname -f with shortname +* Set incorrect tuning param in /etc/foreman-installer/scenarios.d/satellite.yaml +* Create a repo file in /etc/yum.repos.d/ as the rh-cloud.repo. + + +Requirements +------------ + +This ansible role requires the [foreman ansible modules](https://github.com/theforeman/foreman-ansible-modules/). Please install them before executing the role. + +Role Variables +-------------- + +The `vars/main.yml` file contains the required variables for the ansible role. Adjust the values according to your environment. + +Dependencies +------------ + +NA + +Example Playbook +---------------- + +This ansible role can be executed after creating a playbook in the following way. + +~~~ +# cat breakfix1.yaml +--- +- name: Deploy ansible role breakfix1 on target systems + hosts: satellite + roles: + - role: breakfix1 + tags: break +~~~ + +License +------- + +It is free software licensed under the terms of the GNU General Public License GPL v3 or later. A copy of the license can be obtained here: http://www.gnu.org/licenses/gpl-3.0.html + +Author Information +------------------ + +This role is developed by Soham Majumdar , . diff --git a/breakfix1.yaml b/SCENARIO_UPGRADE_INSTALLER/breakfix1.yml similarity index 99% rename from breakfix1.yaml rename to SCENARIO_UPGRADE_INSTALLER/breakfix1.yml index a4fd9d9..84eb7e4 100644 --- a/breakfix1.yaml +++ b/SCENARIO_UPGRADE_INSTALLER/breakfix1.yml @@ -4,3 +4,4 @@ roles: - role: breakfix1 tags: break + diff --git a/SCENARIO_UPGRADE_INSTALLER/breakfix1/tasks/main.yml b/SCENARIO_UPGRADE_INSTALLER/breakfix1/tasks/main.yml new file mode 100644 index 0000000..051dc17 --- /dev/null +++ b/SCENARIO_UPGRADE_INSTALLER/breakfix1/tasks/main.yml @@ -0,0 +1,63 @@ +--- +# tasks file for breakfix1 +- name: Set initial facts + ansible.builtin.set_fact: + satellite_hostname: "{{ ansible_fqdn }}" + +- name: Read credentials + slurp: + path: /root/.hammer/cli.modules.d/foreman.yml + register: slurp + +- name: Set credentials + set_fact: + password: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':password'] }}" + username: "{{ (slurp.content | b64decode | from_yaml)[':foreman'][':username'] }}" + + +- name: Ensure satellite is running. + theforeman.foreman.status_info: + server_url: "https://{{ satellite_hostname }}" + username: "{{ username }}" + password: "{{ password }}" + validate_certs: false + register: status_info + +- name: Clearing content of /etc/hosts + shell: "> /etc/hosts" + +- name: "Create broken entry of /etc/hosts" + blockinfile: + path: /etc/hosts + block: | + 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 + ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 + 192.168.0.158 {{ ansible_facts['fqdn'] }} + +- name: Breaking the hostname + shell: "hostnamectl set-hostname $(hostname -s)" + +- name: Creating a dummy .repo file + shell: "touch /etc/yum.repos.d/rh-cloud.repo" + +- name: Populating content in rh-cloud.repo + blockinfile: + path: /etc/yum.repos.d/rh-cloud.repo + block: | + [rhel-8-for-x86_64-baseos-rpms] + name = Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) + baseurl = http://content.example.com/content/rhel-8-for-x86_64-baseos-rpms/ + gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release + gpgcheck = 1 + enabled = 1 + + [rhel-8-for-x86_64-appstream-rpms] + name = Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) + baseurl = http://content.example.com/content/rhel-8-for-x86_64-appstream-rpms/ + gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release + gpgcheck = 1 + enabled = 1 + +- name: Breaking Tuning profile + shell: "sed -i 's/default/large/' /etc/foreman-installer/scenarios.d/satellite.yaml" + diff --git a/SCENARIO_UPGRADE_INSTALLER/breakfix1/vars/main.yml b/SCENARIO_UPGRADE_INSTALLER/breakfix1/vars/main.yml new file mode 100644 index 0000000..1ffcf73 --- /dev/null +++ b/SCENARIO_UPGRADE_INSTALLER/breakfix1/vars/main.yml @@ -0,0 +1,6 @@ +--- +# vars file for breakfix1 +satellite_organization: "Default Organization" +satellite_location: "Default Location" +activation_key: "RHEL-AK" + diff --git a/SCENARIO_UPGRADE_INSTALLER/grade.yml b/SCENARIO_UPGRADE_INSTALLER/grade.yml new file mode 100644 index 0000000..481dddb --- /dev/null +++ b/SCENARIO_UPGRADE_INSTALLER/grade.yml @@ -0,0 +1,37 @@ +--- +- name: Grading playbook for SCENARIO_UPGRADE_INSTALLER + hosts: satellite + gather_facts: no + tasks: + - name: Extracting satellite_version + shell: "rpm -qa | grep satellite-6 | cut -c13-16" + register: satellite_version + + - name: Extracting exit_code + shell: "tail -5 /var/log/foreman-installer/satellite.log | head -1 | cut -c63-74" + register: exit_code + + - name: see what is captured + debug: + msg: satellite_version is "{{ satellite_version.stdout }}" and exit_code is "{{ exit_code.stdout }}" + + - name: Checking result + ansible.builtin.debug: + msg: Success. your alphanumeric code for completion is UPGRADE615 + when: + - satellite_version.stdout == "15.5" + - exit_code.stdout == "signal was 2" + + - name: Marking the lab valid even when 6.16.6 will be released + ansible.builtin.debug: + msg: Success. your alphanumeric code for completion is UPGRADE615 + when: + - satellite_version.stdout == "15.6" + - exit_code.stdout == "signal was 2" + + - name: In case of failure + ansible.builtin.debug: + msg: "The satellite is not upgraded successfully yet, please try again." + when: + - satellite_version.stdout == "15.4" or exit_code.stdout != "signal was 2" + diff --git a/SCENARIO_UPGRADE_INSTALLER/requirements.yml b/SCENARIO_UPGRADE_INSTALLER/requirements.yml new file mode 100644 index 0000000..119e606 --- /dev/null +++ b/SCENARIO_UPGRADE_INSTALLER/requirements.yml @@ -0,0 +1,7 @@ +--- +collections: + - name: https://github.com/theforeman/foreman-ansible-modules.git + type: git + version: develop + - name: ansible.posix + - name: community.general diff --git a/breakfix1/tasks/main.yml b/breakfix1/tasks/main.yml deleted file mode 100644 index b5b1da0..0000000 --- a/breakfix1/tasks/main.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# tasks file for breakfix1 -- name: Set initial facts - ansible.builtin.set_fact: - satellite_hostname: "{{ ansible_fqdn }}" - -- name: Ensure satellite is running. - theforeman.foreman.status_info: - server_url: "https://{{ satellite_hostname }}" - username: "{{ satellite_login['username'] }}" - password: "{{ satellite_login['password'] }}" - validate_certs: false - register: status_info - -- name: Create client activation key - theforeman.foreman.activation_key: - server_url: "https://{{ satellite_hostname }}" - username: "{{ satellite_login['username'] }}" - password: "{{ satellite_login['password'] }}" - validate_certs: false - name: "{{ activation_key }}" - organization: "{{ satellite_organization }}" - lifecycle_environment: "Library" - content_view: "Default Organization View" - when: status_info['status']['result'] == "ok" - register: ak_created - -- name: Generate registration command to register the system with Capsule server - theforeman.foreman.registration_command: - server_url: "https://{{ satellite_hostname }}" - username: "{{ satellite_login['username'] }}" - password: "{{ satellite_login['password'] }}" - validate_certs: false - setup_remote_execution: true - setup_insights: false - jwt_expiration: 8 - force: true - insecure: true - activation_keys: "{{ activation_key }}" - organization: "{{ satellite_organization }}" - location: "{{ satellite_location }}" - smart_proxy: "{{ groups['capsule'][0] }}" - when: ak_created is success - register: global_reg_command - -- name: Regsiter the client host - ansible.builtin.command: bash -c "{{ global_reg_command['registration_command'] }}" - delegate_to: "{{ groups['client'][0] }}" - register: host_registration - when: global_reg_command is defined - -- name: Break the satellite by adding a proxy in repositories to fail the sync. - ansible.builtin.command: > - su - postgres -c "psql pulpcore -c 'update core_remote set proxy_url = '\''http://localhost:3128'\'' where pulp_type = '\''rpm.rpm'\'';'" - register: break_satellite - when: - - status_info['status']['result'] == "ok" - - host_registration is success - -- name: Break the capsule by adding a proxy in repositories to fail content retrieval from capsule. - ansible.builtin.command: > - su - postgres -c "psql pulpcore -c 'update core_remote set proxy_url = '\''http://localhost:3128'\'' where pulp_type = '\''rpm.rpm'\'';'" - delegate_to: "{{ groups['capsule'][0] }}" - register: break_capsule - when: break_satellite is success diff --git a/breakfix1/vars/main.yml b/breakfix1/vars/main.yml deleted file mode 100644 index b37c7ff..0000000 --- a/breakfix1/vars/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# vars file for breakfix1 -satellite_organization: "RedHat" -satellite_location: "GSS" -satellite_login: - username: "admin" - password: "RedHat1!" -activation_key: "RHEL-AK"