Skip to content

Commit

Permalink
Add support for new platform installation method of AAP 2.5 on OpenSh…
Browse files Browse the repository at this point in the history
…ift (#261)

* Add EDA deployment on OCP

* Update documentation for role change

* Additional checks for EDA variables, and ability to use custom EDA namespace

* Correct linting formatting errors

* Add endline on changelog fragment

* Modifications to support the new OCP deployment method for AAP 2.5

* Template fixes identified during testing

* Make the AAP OCP Deployment backward compatible with pre AAP2.5

* Restore missing files

* Ensure Hub settings are correct

* Update documentation for OCP Installation AAP 2.5+

* Corrected trailing whitespace and line feed errors

* Remove duplication in yml file

* Pre-commit fixes (EOF and github-actions-bot changes)

* Fix Jinja templating errors

* Revert galaxy version definition

* - Allow installation of cluster-scoped AAP into a different namespace
- Wait until controller/eda/hub APIs are available before marking installation complete

* Update documentation to show 2.4- and 2.5+ example playbooks

* Changes from PR code review

* Ensure new install keys are used for component installation, and the correct hub API is tested

* Correct Lightspeed deployment setting in AAP 2.5 OCP install

* Amended README to include platform options for namespace and link text

---------

Co-authored-by: Derek Waters <[email protected]>
Co-authored-by: Brant Evans <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2025
1 parent 84df647 commit 042585f
Show file tree
Hide file tree
Showing 9 changed files with 587 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/add_ocp_aap25_support.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Added support to allow installation of AAP 2.5 using the new platform operator method
94 changes: 92 additions & 2 deletions roles/aap_ocp_install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ A description of the settable variables for this role should go here, including
| aap_ocp_install_operator | Yes* | None | YAML Manifest to override the generated operator `Namespace` resource |
| aap_ocp_install_controller | Yes* | None | Dictionary containing keys defined in the `controller variables table` |
| aap_ocp_install_hub | Yes* | None | Dictionary containing keys defined in the `hub variables table` |
| aap_ocp_install_eda | Yes* | None | Dictionary containing keys defined in the `eda variables table` |
| aap_ocp_install_platform | Yes* | None | Dictionary containing keys defined in the `platform variables table` |
| aap_ocp_install_lightspeed | No | None | Dictionary containing keys defined in the `lightspeed variables table` |

\* Variable and required keys must be defined when the type of tag is specified (e.g. `--tags controller` requires the aap_ocp_install_controller variable be defined).
If the variable is omitted the corresponding component will not be installed (e.g. if only aap_ocp_install_hub variable is defined then the operator and controller installation will be skipped)

The aap_ocp_install_platform and aap_ocp_install_lightspeed Dictionaries are only used when installing AAP 2.5 or later.

### aap_ocp_install_connection keys

| Key Name | Required | Default Value | Description |
Expand All @@ -40,12 +45,14 @@ If the variable is omitted the corresponding component will not be installed (e.

| Key Name | Required | Default Value | Description |
|----------------------------------|:---------:|---------------|---------------------------------------------------------------------|
| channel | Yes | None | Channel to subscribe (e.g. stable-2.2 or stable-2.2-cluster-scoped) |
| channel | Yes* | None | Channel to subscribe (e.g. stable-2.2 or stable-2.2-cluster-scoped) |
| approval | | Automatic | Update approval method. Valid values are Automatic or Manual. |
| operatorgroup_create | | true | Create the `OperatorGroup` for the Operator |
| operatorgroup_manifest_overrides | | | YAML Manifest to override the generated `OperatorGroup` resource |
| subscription_manifest_overrides | | | YAML Manifest to override the generated `Subscription` resource |

\* If the channel indicates version 2.5 or above of AAP, then the new AAP operator platform installation method will be used.

> ℹ️ **NOTE**
>
> When `approval` is set to `Manual` the operator will be installed with `Automatic` approval and then after installation the approval will be updated to Manual.
Expand All @@ -67,6 +74,13 @@ If the variable is omitted the corresponding component will not be installed (e.
| link_text | | Automation Controller (<INSTANCE_NAME>) | Text used for creating the OCP application link |
| controller_manifest_overrides | | None | YAML Manifest to override the generated `AutomationController` resource link |
| consolelink_manifest_overrides | | None | YAML Manifest to override the generated `ConsoleLink` resource |
| install | * | false | Whether or not to install the Controller platform component in AAP 2.5 or later |

\* These settings are only used for installing AAP 2.5 or later.

> ℹ️ **NOTE**
>
> The namespace, instance_name and link_text values will be ignored when using the platform installation method.
### aap_ocp_install_hub keys

Expand All @@ -78,6 +92,18 @@ If the variable is omitted the corresponding component will not be installed (e.
| link_text | | Automation Hub (<INSTANCE_NAME>) | Text used for creating the OCP application link |
| hub_manifest_overrides | | None | YAML Manifest to override the generated `AutomationHub` resource |
| consolelink_manifest_overrides | | None | YAML Manifest to override the generated `ConsoleLink` resource |
| storage_type | * | file | Hub storage type (file, S3 or azure) |
| file_storage_storage_class | * | None | OpenShift StorageClass to use for file storage type for hub |
| file_storage_size | * | 10Gi | Storage size for file storage type for hub |
| object_storage_s3_secret | * | None | Name of an OpenShift Secret used to access S3 storage for hub |
| object_storage_azure_secret | * | None | Name of an OpenShift Secret used to access Azure storage for hub |
| install | * | false | Whether or not to install the Hub platform component in AAP 2.5 or later |

\* These settings are only used for installing AAP 2.5 or later.

> ℹ️ **NOTE**
>
> The namespace, instance_name and link_text values will be ignored when using the platform installation method.
### aap_ocp_install_eda keys

Expand All @@ -89,14 +115,43 @@ If the variable is omitted the corresponding component will not be installed (e.
| link_text | | EDA Controller (<INSTANCE_NAME>) | Text used for creating the OCP application link |
| eda_manifest_overrides | | None | YAML Manifest to override the generated `EDA` resource |
| consolelink_manifest_overrides | | None | YAML Manifest to override the generated `ConsoleLink` resource |
| install | * | false | Whether or not to install the EDA platform component in AAP 2.5 or later |

\* These settings are only used for installing AAP 2.5 or later.

> ℹ️ **NOTE**
>
> The namespace, instance_name and link_text values will be ignored when using the platform installation method.
### aap_ocp_install_platform keys

| Key Name | Required | Default Value | Description |
|---------------|:--------:|----------------------------------|-------------------------------------------------|
| instance_name | Yes | None | Name of the AAP Platform instance to create |
| namespace | | None | Name of the namespace to create the AAP platform instance in. If not specified `aap_ocp_install_namespace` will be used. |
| link_text | | (<INSTANCE_NAME>) | Text used for creating the platform OCP application link |

> ℹ️ **NOTE**
>
> These settings are only used when installing AAP 2.5 or later. namespace, instance_name and link_text values for individual components (hub, controller, eda) will be ignored when using the platform installation method.
### aap_ocp_install_lightspeed keys

| Key Name | Required | Default Value | Description |
|---------------|:--------:|----------------------------------|-------------------------------------------------|
| install | No | false | Whether or not to install the platform Lightspeed components |

> ℹ️ **NOTE**
>
> These settings are only used when installing AAP 2.5 or later.
## Dependencies

This role depends on the redhat.openshift and kubernetes.core collections.

## Example Playbook

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
The following playbook will install AAP versions 2.4 and earlier:

```yml
---
Expand Down Expand Up @@ -125,6 +180,41 @@ Including an example of how to use your role (for instance, with variables passe
...
```

The following playbook will install AAP versions 2.5 and later:

```yml
---
- name: Install AAP on OCP playbook 2.5+
hosts: localhost
gather_facts: false

vars:
aap_ocp_install_connection:
host: "https://api.crc.testing:6443"
username: kubeadmin
password: <PASSWORD>
validate_certs: false
aap_ocp_install_namespace: aap-test
aap_ocp_install_operator:
channel: "stable-2.5-cluster-scoped"
aap_ocp_install_platform:
instance_name: automationcontroller
namespace: aap-platform
aap_ocp_install_controller:
install: true
aap_ocp_install_eda:
install: true
aap_ocp_install_hub:
install: true
storage_type: file
file_storage_storage_class: my-filestore-rwx
file_storage_size: 30Gi

roles:
- infra.aap_utilities.aap_ocp_install
...
```

## License

[GPLv3+0](https://github.com/redhat-cop/aap_utilities#licensing)
Expand Down
13 changes: 13 additions & 0 deletions roles/aap_ocp_install/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# aap_ocp_install_operator:
# channel:

# Variables applicable to the Ansible platform installation
# aap_ocp_install_platform:
# instance_name:

# Variable applicable to the controller installation
# aap_ocp_install_controller:
# instance_name:
Expand All @@ -24,11 +28,20 @@
# aap_ocp_install_hub:
# instance_name:
# link_text:
# storage_type:
# file_storage_storage_class:
# file_storage_size:
# object_storage_s3_secret:
# object_storage_azure_secret:

# Variable applicable to the EDA installation
# aap_ocp_install_eda:
# namespace:
# instance_name:
# replicas:
# link_text:

# Variables applicable to the Lightspeed installation
# aap_ocp_install_lightspeed:
#
...
172 changes: 172 additions & 0 deletions roles/aap_ocp_install/tasks/install-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
---
- name: Create platform namespace
kubernetes.core.k8s:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
state: present
resource_definition: "{{ lookup('ansible.builtin.template', 'namespace.yaml.j2', template_vars=ns_vars) | from_yaml }}"
apply: true
vars:
ns_vars:
ns_name: "{{ aap_ocp_install_platform['namespace'] }}"
when:
- aap_ocp_install_platform['namespace'] is defined

- name: Create automation platform instance
kubernetes.core.k8s:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
state: present
resource_definition: "{{ lookup('template', 'platform/instance.yaml.j2') | from_yaml }}"
apply: true

- name: Wait for operator to create the automation platform route
kubernetes.core.k8s_info:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
kind: Route
name: "{{ aap_ocp_install_platform['instance_name'] | mandatory }}"
api_version: route.openshift.io/v1
namespace: "{{ aap_ocp_install_platform['namespace'] | default(aap_ocp_install_namespace) | mandatory }}"
register: __aap_ocp_install_platform_route_result
until: __aap_ocp_install_platform_route_result['resources']
retries: 60 # Wait for 15 minutes (60*15/60)
delay: 15

- name: Store automation platform route
ansible.builtin.set_fact:
__aap_ocp_install_platform_route: "{{ __aap_ocp_install_platform_route_result['resources'][0]['status']['ingress'][0]['host'] }}"

- name: Ensure automation platform login is available
ansible.builtin.uri:
url: "https://{{ __aap_ocp_install_platform_route }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
method: GET
status_code:
- 200
register: _aap_ocp_install_platform_available
until: (_aap_ocp_install_platform_available['status'] == 200) and ('migrations_notran' not in _aap_ocp_install_platform_available['url'])
retries: 120 # Wait for 30 minutes (120*15/60)
delay: 15

# Ensure that all of the platform components are also available
- name: Wait for operator to create the automation controller route
kubernetes.core.k8s_info:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
kind: Route
name: "{{ aap_ocp_install_platform['instance_name'] | mandatory }}-controller"
api_version: route.openshift.io/v1
namespace: "{{ aap_ocp_install_platform['namespace'] | default(aap_ocp_install_namespace) | mandatory }}"
when:
- aap_ocp_install_controller is defined and aap_ocp_install_controller['install'] is defined and aap_ocp_install_controller['install']
register: __aap_ocp_install_controller_route_result
until: __aap_ocp_install_controller_route_result['resources']
retries: 60 # Wait for 15 minutes (60*15/60)
delay: 15

- name: Store automation controller route
ansible.builtin.set_fact:
__aap_ocp_install_controller_route: "{{ __aap_ocp_install_controller_route_result['resources'][0]['status']['ingress'][0]['host'] }}"
when:
- aap_ocp_install_controller is defined and aap_ocp_install_controller['install'] is defined and aap_ocp_install_controller['install']

- name: Ensure automation controller API is available
ansible.builtin.uri:
url: "https://{{ __aap_ocp_install_controller_route }}/api"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
method: GET
status_code:
- 200
when:
- aap_ocp_install_controller is defined and aap_ocp_install_controller['install'] is defined and aap_ocp_install_controller['install']
register: _aap_ocp_install_controller_available
until: (_aap_ocp_install_controller_available['status'] == 200) and ('migrations_notran' not in _aap_ocp_install_controller_available['url'])
retries: 120 # Wait for 30 minutes (120*15/60)
delay: 15

- name: Wait for operator to create the automation EDA route
kubernetes.core.k8s_info:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
kind: Route
name: "{{ aap_ocp_install_platform['instance_name'] | mandatory }}-eda"
api_version: route.openshift.io/v1
namespace: "{{ aap_ocp_install_platform['namespace'] | default(aap_ocp_install_namespace) | mandatory }}"
when:
- aap_ocp_install_eda is defined and aap_ocp_install_eda['install'] is defined and aap_ocp_install_eda['install']
register: __aap_ocp_install_eda_route_result
until: __aap_ocp_install_eda_route_result['resources']
retries: 60 # Wait for 15 minutes (60*15/60)
delay: 15

- name: Store automation eda route
ansible.builtin.set_fact:
__aap_ocp_install_eda_route: "{{ __aap_ocp_install_eda_route_result['resources'][0]['status']['ingress'][0]['host'] }}"
when:
- aap_ocp_install_eda is defined and aap_ocp_install_eda['install'] is defined and aap_ocp_install_eda['install']

- name: Ensure automation eda API is available
ansible.builtin.uri:
url: "https://{{ __aap_ocp_install_eda_route }}/api"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
method: GET
status_code:
- 200
when:
- aap_ocp_install_eda is defined and aap_ocp_install_eda['install'] is defined and aap_ocp_install_eda['install']
register: _aap_ocp_install_eda_available
until: (_aap_ocp_install_eda_available['status'] == 200) and ('migrations_notran' not in _aap_ocp_install_eda_available['url'])
retries: 120 # Wait for 30 minutes (120*15/60)
delay: 15

- name: Wait for operator to create the automation hub route
kubernetes.core.k8s_info:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
kind: Route
name: "{{ aap_ocp_install_platform['instance_name'] | mandatory }}-hub"
api_version: route.openshift.io/v1
namespace: "{{ aap_ocp_install_platform['namespace'] | default(aap_ocp_install_namespace) | mandatory }}"
when:
- aap_ocp_install_hub is defined and aap_ocp_install_hub['install'] is defined and aap_ocp_install_hub['install']
register: __aap_ocp_install_hub_route_result
until: __aap_ocp_install_hub_route_result['resources']
retries: 60 # Wait for 15 minutes (60*15/60)
delay: 15

- name: Store automation hub route
ansible.builtin.set_fact:
__aap_ocp_install_hub_route: "{{ __aap_ocp_install_hub_route_result['resources'][0]['status']['ingress'][0]['host'] }}"
when:
- aap_ocp_install_hub is defined and aap_ocp_install_hub['install'] is defined and aap_ocp_install_hub['install']

- name: Ensure automation hub API is available
ansible.builtin.uri:
url: "https://{{ __aap_ocp_install_hub_route }}/api/galaxy/pulp/api/v3/"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
method: GET
status_code:
- 200
when:
- aap_ocp_install_hub is defined and aap_ocp_install_hub['install'] is defined and aap_ocp_install_hub['install']
register: _aap_ocp_install_hub_available
until: (_aap_ocp_install_hub_available['status'] == 200) and ('migrations_notran' not in _aap_ocp_install_hub_available['url'])
retries: 120 # Wait for 30 minutes (120*15/60)
delay: 15

- name: Create automation platform console link
kubernetes.core.k8s:
host: "{{ __aap_ocp_install_auth_results['openshift_auth']['host'] }}"
api_key: "{{ __aap_ocp_install_auth_results['openshift_auth']['api_key'] }}"
validate_certs: "{{ aap_ocp_install_connection['validate_certs'] | default(omit) }}"
state: present
resource_definition: "{{ lookup('template', 'platform/consolelink.yaml.j2') | from_yaml }}"
apply: true
...
Loading

0 comments on commit 042585f

Please sign in to comment.