Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #35970 - add orcharhino branding to upgrading Smart Proxies #586

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ feature: ansible_run_capsule_upgrade
target_version: "<%= input('target_version').present? ? input('target_version') : product_short_version %>"
tasks:
<% if plugin_present?('foreman_theme_satellite') -%>
- name: Gather the rpm package facts
package_facts:
- name: Gather RPM package facts
ansible.builtin.package_facts:
manager: auto

- name: Fail if the target server is a Satellite server
fail:
- name: Fail if target is a Satellite server
ansible.builtin.fail:
msg: "This playbook cannot be executed on a Satellite server. Use only on a Capsule server."
when: "'satellite' in ansible_facts.packages"

- name: Install|Update satellite-maintain if not present
package:
ansible.builtin.package:
name: rubygem-foreman_maintain
state: latest

Expand All @@ -47,35 +47,35 @@ feature: ansible_run_capsule_upgrade
"--whitelist=#{input('whitelist_options')}"
end -%>
- name: Upgrade Capsule server using satellite-maintain
shell: satellite-maintain upgrade run --assumeyes --target-version={{ target_version }} <%= whitelist_option %>
ansible.builtin.shell: satellite-maintain upgrade run --assumeyes --target-version={{ target_version }} <%= whitelist_option %>
register: result

- name: Re-Gather the rpm package facts after the upgrade
package_facts:
- name: Re-Gather RPM package facts after the upgrade
ansible.builtin.package_facts:
manager: auto

- name: satellite-maintain upgrade return code is zero
debug:
msg: "Success! Capsule server upgrade completed. Current version of Capsule server server is {{ ansible_facts.packages['satellite-capsule'][0]['version'] }}."
ansible.builtin.debug:
msg: "Success! Capsule server upgrade completed. Current version of Capsule server is {{ ansible_facts.packages['satellite-capsule'][0]['version'] }}."

rescue:
- name: Print satellite-maintain output
debug:
ansible.builtin.debug:
var: result

- name: Grep top 10 Error messages from /var/log/foreman-installer/capsule.log
shell: grep '^\[ERROR' /var/log/foreman-installer/capsule.log | head -n10
ansible.builtin.shell: grep '^\[ERROR' /var/log/foreman-installer/capsule.log | head -n10
register: output_grep

- name: Print grepped Error messages
debug:
ansible.builtin.debug:
var: output_grep.stdout_lines

- name: satellite-maintain upgrade return code is non-zero
fail:
msg: "Failed! Capsule server upgrade failed. See /var/log/foreman-installer/capsule.log in the Capsule server for more information"
ansible.builtin.fail:
msg: "Failed! Capsule server upgrade failed. For more information, see /var/log/foreman-installer/capsule.log on your Capsule server."
<% else -%>
- name: Fail if foreman_theme_satellite is missing
fail:
ansible.builtin.fail:
msg: "Failed! The plugin foreman_theme_satellite is not present. This playbook is only for use with Satellite."
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<%#
name: orcharhino Proxy Upgrade Playbook
snippet: false
model: JobTemplate
job_category: Maintenance Operations
description_format: "%{template_name}"
provider_type: Ansible
kind: job_template
feature: ansible_run_orcharhino_proxy_upgrade
%>

---
- hosts: all
tasks:
<% if plugin_present?('orcharhino_core') -%>
- name: Gather RPM package facts
ansible.builtin.package_facts:
manager: auto

- name: Fail if target is orcharhino Server
ansible.builtin.fail:
msg: "This playbook cannot be executed on orcharhino Server. Use only on orcharhino Proxy."
when: "'orcharhino' in ansible_facts.packages"

- block:
- name: Update all packages on orcharhino Proxy
ansible.builtin.package:
name: "*"
state: latest
register: result

- name: Run orcharhino-installer
ansible.builtin.shell: orcharhino-installer
register: result

- name: Re-Gather RPM package facts after the upgrade
ansible.builtin.package_facts:
manager: auto

- name: orcharhino-maintain upgrade return code is zero
ansible.builtin.debug:
msg: "Success! orcharhino Proxy upgrade completed. Current version of orcharhino Proxy is {{ ansible_facts.packages['orcharhino-proxy'][0]['version'] }}."

rescue:
- name: orcharhino-maintain upgrade return code is non-zero
ansible.builtin.fail:
msg: "Failed! orcharhino Proxy upgrade failed. For more information, see /var/log/foreman-installer/foreman-proxy-content.log on your orcharhino Proxy."
<% else -%>
- name: Fail if orcharhino_core is missing
ansible.builtin.fail:
msg: "Failed! The plug-in orcharhino_core is not present. This playbook is only for use with orcharhino."
<% end -%>
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,33 @@ feature: ansible_run_smart_proxy_upgrade
vars:
target_version: "<%= input('target_version').present? ? input('target_version') : product_short_version %>"
tasks:
- name: Gather the rpm package facts
package_facts:
- name: Gather RPM package facts
ansible.builtin.package_facts:
manager: auto

- name: Fail if the target server is a Foreman server
fail:
- name: Fail if target is a Foreman server
ansible.builtin.fail:
msg: "This playbook cannot be executed on a Foreman server. Use only on a Smart Proxy server."
when: "'foreman' in ansible_facts.packages"

- name: Install foreman release gpg key
rpm_key:
- name: Install Foreman release GPG key
ansible.builtin.rpm_key:
state: present
key: http://yum.theforeman.org/releases/{{ target_version }}/RPM-GPG-KEY-foreman
when: target_version != "nightly"

- name: Update foreman repositories
package:
- name: Update Foreman repositories
ansible.builtin.package:
name: https://yum.theforeman.org/releases/{{ target_version }}/el{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/foreman-release.rpm
state: installed

- name: Clean yum metadata
command: yum clean all
ansible.builtin.command: yum clean all

- name: Update all packages
package:
ansible.builtin.package:
name: '*'
state: latest

- name: Run the installer
shell: foreman-installer
ansible.builtin.shell: foreman-installer