-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
168 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
collections: | ||
- name: ansible.posix | ||
- name: middleware_automation.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
- name: "Ensure required parameters are provided" | ||
ansible.builtin.assert: | ||
that: | ||
- rhn_username is defined and rhn_username | length > 0 | ||
- rhn_password is defined and rhn_password | length > 0 | ||
- rhn_product_id is defined and rhn_product_id | length > 0 | ||
- rhn_product_path is defined and rhn_product_path | length > 0 | ||
quiet: True | ||
|
||
- name: "Load metadata on target location for download ({{ rhn_product_path }})" | ||
ansible.builtin.stat: | ||
path: "{{ rhn_product_path | dirname }}" | ||
register: rhn_product_path_metadata | ||
delegate_to: localhost | ||
become: "{{ rhn_download_become | default(False) }}" | ||
|
||
- name: "Ensure {{ rhn_product_path }} is accessible" | ||
ansible.builtin.assert: | ||
that: | ||
- rhn_product_path_metadata is defined and rhn_product_path_metadata.stat is defined | ||
- rhn_product_path_metadata.stat.writeable is defined and rhn_product_path_metadata.stat.writeable | ||
quiet: True | ||
fail_msg: "Path for download product is not writeable on the Ansible controller: {{ rhn_product_path }}." | ||
|
||
- name: "Download Red Hat product into {{ rhn_product_path }} (rhn_download_become: {{ rhn_download_become }})" | ||
middleware_automation.common.product_download: # noqa risky-file-permissions delegated, uses controller host user | ||
client_id: "{{ rhn_username }}" | ||
client_secret: "{{ rhn_password }}" | ||
product_id: "{{ rhn_product_id }}" | ||
dest: "{{ rhn_product_path }}" | ||
no_log: "{{ omit_rhn_output | default(true) }}" | ||
delegate_to: localhost | ||
run_once: yes | ||
become: "{{ rhn_download_become | default(False) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- name: "Automate AMQ Streams install" | ||
hosts: all | ||
vars: | ||
rhn_product_version: 2.5.1 | ||
rhn_product_path_pattern: '^.*/amq-streams-[0-9.]*-bin.zip$' | ||
# Topic Management | ||
amq_streams_broker_topics: | ||
- name: sampleTopic | ||
partitions: 2 | ||
replication_factor: 1 | ||
- name: otherTopic | ||
partitions: 4 | ||
replication_factor: 1 | ||
tasks: | ||
- name: "Ensure AMQ Streams Broker is running and available." | ||
ansible.builtin.include_role: | ||
name: amq_streams_common | ||
tasks_from: rhn/search.yml | ||
vars: | ||
rhn_product_type: 'DISTRIBUTION' | ||
rhn_product_category: 'jboss.amq.streams' | ||
|
||
- ansible.builtin.debug: | ||
var: rhn_products.results | ||
|
||
- name: Determine patch versions list | ||
ansible.builtin.set_fact: | ||
filtered_versions: "{{ rhn_products.results | map(attribute='file_path') | select('match', rhn_product_path_pattern) | map('regex_replace','[^/]*/amq-streams-([0-9]*[.][0-9]*[.][0-9]*)-.*','\\1' ) | list | unique }}" | ||
delegate_to: localhost | ||
run_once: yes | ||
|
||
- name: Determine latest version | ||
ansible.builtin.set_fact: | ||
rhn_product_latest_version: "{{ filtered_versions | middleware_automation.common.version_sort | last }}" | ||
delegate_to: localhost | ||
run_once: yes | ||
|
||
- ansible.builtin.debug: | ||
var: rhn_product_latest_version | ||
|
||
- name: "TODO" | ||
ansible.builtin.set_fact: | ||
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '^.*/amq-streams-[0-9.]*-bin.zip$') }}" | ||
|
||
- ansible.builtin.debug: | ||
var: rhn_filtered_products | ||
|
||
- name: "Download " | ||
ansible.builtin.include_role: | ||
name: amq_streams_common | ||
tasks_from: rhn/download.yml | ||
vars: | ||
rhn_product_id: "{{ rhn_filtered_products[0].id }}" | ||
rhn_product_path: /tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
- name: "Ensure required parameters are provided." | ||
ansible.builtin.assert: | ||
that: | ||
- amq_streams_common_download_dir is defined | ||
quiet: true | ||
|
||
- name: "Search RHN artefact for {{ amq_streams_common_rhn_product_version }}." | ||
ansible.builtin.include_role: | ||
name: amq_streams_common | ||
tasks_from: rhn/search.yml | ||
vars: | ||
rhn_product_type: 'DISTRIBUTION' | ||
rhn_product_category: "{{ amq_streams_common_rhn_product_category }}" | ||
rhn_product_version: "{{ amq_streams_common_rhn_product_version }}" #"{{ amq_version.split('.')[:2] | join('.') }}" | ||
|
||
- name: "Determine which archive to download" | ||
ansible.builtin.set_fact: | ||
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '^.*/amq-streams-[0-9.]*-bin.zip$') }}" | ||
|
||
- name: "Download rhn_filtered_products[0]" | ||
ansible.builtin.include_role: | ||
name: amq_streams_common | ||
tasks_from: rhn/download.yml | ||
vars: | ||
rhn_product_id: "{{ rhn_filtered_products[0].id }}" | ||
rhn_product_path: "{{ amq_streams_common_download_dir }}" | ||
|
||
- name: "XXX" | ||
ansible.builtin.set_fact: | ||
amq_streams_common_archive_file: "amq-streams-{{ amq_streams_common_rhn_product_version }}-bin.zip" | ||
amq_streams_common_home: "{{ amq_streams_common_install_dir }}/{{ amq_streams_common_rhn_home_dir }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
- name: "Ensure required parameters are provided" | ||
ansible.builtin.assert: | ||
that: | ||
- rhn_username is defined and rhn_username | length > 0 | ||
- rhn_password is defined and rhn_password | length > 0 | ||
- rhn_product_category is defined and rhn_product_category | length > 0 | ||
- rhn_product_type is defined | ||
- rhn_product_version is defined and rhn_product_version | length > 0 | ||
- rhn_product_type == 'BUGFIX' or rhn_product_type == 'DISTRIBUTION' | ||
quiet: True | ||
|
||
- name: Retrieve product download using JBossNetwork API | ||
middleware_automation.common.product_search: | ||
client_id: "{{ rhn_username }}" | ||
client_secret: "{{ rhn_password }}" | ||
product_type: "{{ rhn_product_type }}" | ||
product_version: "{{ rhn_product_version }}" | ||
product_category: "{{ rhn_product_category }}" | ||
register: rhn_products | ||
no_log: "{{ omit_rhn_output | default(true) }}" | ||
delegate_to: localhost | ||
become: "{{ rhn_download_become | default(False) }}" | ||
run_once: yes | ||
|
||
- name: "Ensure search results are valid." | ||
ansible.builtin.assert: | ||
that: | ||
- rhn_products is defined | ||
- rhn_products.results is defined | ||
quiet: True | ||
fail_msg: "Invalid results returned: {{ rhn_products }}" |