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

New activemq_uninstall role #150

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
with:
fqcn: 'middleware_automation/amq'
molecule_tests: >-
[ "default", "static_cluster", "amq_upgrade", "mask_passwords", "custom_xml" ]
[ "default", "static_cluster", "amq_upgrade", "mask_passwords", "custom_xml", "uninstall" ]
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: middleware_automation
name: amq
version: "2.1.2"
version: "2.2.0"
readme: README.md
authors:
- Guido Grazioli <[email protected]>
Expand Down
8 changes: 8 additions & 0 deletions molecule/uninstall/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Converge
hosts: all
gather_facts: yes
vars:
activemq_service_user_home: /home/activemq
roles:
- middleware_automation.amq.activemq_uninstall
47 changes: 47 additions & 0 deletions molecule/uninstall/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
driver:
name: docker
platforms:
- name: instance
image: registry.access.redhat.com/ubi9/ubi-init:latest
pre_build_image: true
privileged: true
command: "/usr/sbin/init"
tmpfs:
- /run
- /tmp
port_bindings:
- 8161:8161
published_ports:
- 0.0.0.0:8161:8161/TCP
provisioner:
name: ansible
config_options:
defaults:
interpreter_python: auto_silent
ssh_connection:
pipelining: false
playbooks:
prepare: prepare.yml
converge: converge.yml
verify: verify.yml
inventory:
host_vars:
localhost:
ansible_python_interpreter: "{{ ansible_playbook_python }}"
env:
ANSIBLE_FORCE_COLOR: "true"
verifier:
name: ansible
scenario:
test_sequence:
- cleanup
- destroy
- create
- prepare
- converge
- idempotence
- side_effect
- verify
- cleanup
- destroy
67 changes: 67 additions & 0 deletions molecule/uninstall/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
- name: Prepare
hosts: all
tasks:
- name: "Run preparation common to all scenario"
ansible.builtin.include_tasks: ../prepare.yml

- name: Install
hosts: all
gather_facts: yes
vars:
activemq_service_user_home: /home/activemq
activemq_hawtio_role: admin
activemq_users:
- user: amq
password: amqbrokerpass
roles: [ admin ]
- user: other
password: amqotherpass
roles: [ consumer, producer ]
activemq_roles:
- name: admin
permissions: [ createNonDurableQueue, deleteNonDurableQueue, createDurableQueue, deleteDurableQueue, createAddress, deleteAddress, consume, browse, send, manage ]
- name: manager
permissions: [ browse, manage ]
- name: topicsmanager
match: topics.#
permissions: [ createNonDurableQueue, deleteNonDurableQueue, createDurableQueue, deleteDurableQueue, browse, manage ]
- name: consumer
match: topics.#
permissions: [ consume, browse ]
- name: producer
match: topics.#
permissions: [ send, browse ]
activemq_acceptors:
- name: artemis
bind_address: "{{ activemq_host }}"
bind_port: "{{ activemq_port }}"
parameters:
tcpSendBufferSize: 1048576
tcpReceiveBufferSize: 1048576
protocols: CORE,MQTT
useEpoll: true
- name: amqp
scheme: tcp
bind_address: "{{ activemq_host }}"
bind_port: "{{ activemq_port_amqp }}"
parameters:
tcpSendBufferSize: 1048576
tcpReceiveBufferSize: 1048576
protocols: AMQP
useEpoll: true
amqpMinLargeMessageSize: 102400
amqpCredits: 1000
amqpLowCredits: 300
amqpDuplicateDetection: true
- name: invm
scheme: vm
activemq_diverts:
- name: TESTDIVERT
address: queue.in
forwarding_address: queue.out
routing_type: ANYCAST
filter: "msgType LIKE '%ff%'"
exclusive: True
roles:
- middleware_automation.amq.activemq
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not the new "good" syntax like that:

roles:
  - name: middleware_automation.amq.activemq

?

1 change: 1 addition & 0 deletions molecule/uninstall/roles
35 changes: 35 additions & 0 deletions molecule/uninstall/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
- name: Verify
hosts: all
become: yes
tasks:
- name: Populate service facts
ansible.builtin.service_facts:

- name: Check if amq-broker service is started
ansible.builtin.assert:
that:
- '"amq-broker.service" not in ansible_facts.services'

- name: Check install dir
ansible.builtin.stat:
path: /opt/amq/amq-broker/
register: broker_bin

- name: Check install dir
ansible.builtin.stat:
path: /opt/amq/
register: broker_artemis

- name: Check user homedir
ansible.builtin.stat:
path: /home/activemq
register: broker_user

- name: Verify uninstall
ansible.builtin.assert:
that:
- not broker_user.stat.exists or activemq_uninstall_skip_user
- not broker_artemis.stat.exists or activemq_uninstall_skip_artemis
- not broker_bin.stat.exists
quiet: true
59 changes: 59 additions & 0 deletions roles/activemq_uninstall/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
activemq_uninstall
==================

Uninstalls an activemq service that was installed by the activemq role.


Dependencies
------------

The role depends on the following collections:

* [middleware_automation.common](https://github.com/ansible-middleware/common)
* [ansible.posix](https://github.com/ansible-collections/ansible.posix)

To install, from the collection root directory, run:

ansible-galaxy collections install -r requirements.yml


<!--start argument_specs-->
Role Defaults
-------------

#### Parameters specific to uninstall role

| Variable | Description | Default |
|:---------|:------------|:--------|
|`activemq_uninstall_skip_user`| Whether to skip user/group account deletion | `false` |
|`activemq_uninstall_skip_zipfile`| Whether to skip installation zipfile deletion | `false` |
|`activemq_uninstall_skip_artemis`| Whether to skip artemis directory deletion | `false` |


#### Parameters as used with activemq role

| Variable | Description | Default |
|:---------|:------------|:--------|
|`activemq_version`| Apache Artemis version | `2.34.0` |
|`activemq_archive`| Apache Artemis install archive filename | `apache-artemis-{{ activemq_version }}-bin.zip` |
|`activemq_installdir`| Apache Artemis Installation path | `{{ activemq_dest }}/apache-artemis-{{ activemq_version }}` |
|`activemq_dest`| Root installation directory | `/opt/amq` |
|`activemq_service_user`| POSIX user running the service | `amq-broker` |
|`activemq_service_group`| POSIX group running the service | `amq-broker` |
|`activemq_service_name`| systemd service unit name | `activemq` |
|`activemq_service_user_home`| Service user home directory, defaults to artemis installation directory | `{{ activemq_dest }}/apache-artemis-{{ activemq_version }}` |
|`activemq_instance_name`| Name of broker instance to deploy | `amq-broker` |
|`activemq_configure_firewalld`| Whether to install and configure firewalld | `False` |
|`activemq_shared_storage`| Use shared filesystem directory for storage | `False` |
|`activemq_shared_storage_path`| Absolute path of shared directory | `{{ activemq_dest }}/{{ activemq_instance_name }}/data/shared` |
|`activemq_shared_storage_mounted`| Whether the systemd unit must require a mounted path (only when using shared storage) | `True` |


Example Playbook
----------------
```
---
- hosts: all
roles:
- middleware_automation.amq.activemq_uninstall
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark on the role inclusion syntax.

```
30 changes: 30 additions & 0 deletions roles/activemq_uninstall/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
### Parameters as used with activemq role
activemq_version: 2.34.0

Check warning on line 3 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_version)
activemq_archive: "apache-artemis-{{ activemq_version }}-bin.zip"

Check warning on line 4 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_archive)
activemq_installdir: "{{ activemq_dest }}/apache-artemis-{{ activemq_version }}"

Check warning on line 5 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_installdir)
activemq_dest: /opt/amq

Check warning on line 6 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_dest)
activemq_service_user: amq-broker

Check warning on line 7 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_service_user)
activemq_service_group: amq-broker

Check warning on line 8 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_service_group)
activemq_service_user_home: "{{ activemq_dest }}/apache-artemis-{{ activemq_version }}"

Check warning on line 9 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_service_user_home)
activemq_instance_name: amq-broker

Check warning on line 10 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_instance_name)
activemq_service_pidfile: data/artemis.pid

Check warning on line 11 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_service_pidfile)
activemq_configure_firewalld: false

Check warning on line 12 in roles/activemq_uninstall/defaults/main.yml

View workflow job for this annotation

GitHub Actions / ci / linter (3.11, 2.15)

var-naming[no-role-prefix]

Variables names from within roles should use activemq_uninstall_ as a prefix. (vars: activemq_configure_firewalld)
activemq_name: 'Apache ActiveMQ'
activemq_service_name: activemq
activemq_data_directory: "{{ activemq_shared_storage_path if activemq_shared_storage else activemq_dest + '/' + activemq_instance_name + '/data' }}"
activemq_paging_directory: "{{ activemq_data_directory }}/paging"
activemq_bindings_directory: "{{ activemq_data_directory }}/bindings"
activemq_journal_directory: "{{ activemq_data_directory }}/journal"
activemq_large_messages_directory: "{{ activemq_data_directory }}/largemessages"
activemq_shared_storage: false
activemq_shared_storage_mounted: true
activemq_shared_storage_path: "{{ activemq_dest }}/{{ activemq_instance_name }}/data/shared"

### Parameters specific to uninstall role
# skip user/group deletion
activemq_uninstall_skip_user: false
# skip install zipfile deletion
activemq_uninstall_skip_zipfile: false
# skip artemis install deletion
activemq_uninstall_skip_artemis: false
129 changes: 129 additions & 0 deletions roles/activemq_uninstall/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
argument_specs:
main:
options:
activemq_version:
default: "2.34.0"
description: "Apache Artemis version"
type: "str"
activemq_archive:
default: "apache-artemis-{{ activemq_version }}-bin.zip"
description: "Apache Artemis install archive filename"
type: "str"
activemq_installdir:
default: "{{ activemq_dest }}/apache-artemis-{{ activemq_version }}"
description: "Apache Artemis Installation path"
type: "str"
activemq_service_user_home:
default: "{{ activemq_dest }}/apache-artemis-{{ activemq_version }}"
description: "Service user home directory, defaults to artemis installation directory"
type: "str"
activemq_dest:
default: "/opt/activemq"
description: "Root installation directory"
type: "str"
activemq_service_user:
default: "amq-broker"
description: "POSIX user running the service"
type: "str"
activemq_service_group:
default: "amq-broker"
description: "POSIX group running the service"
type: "str"
activemq_instance_name:
default: "amq-broker"
description: "Name of broker instance to deploy"
type: "str"
activemq_service_pidfile:
default: "data/artemis.pid"
description: "PID file for service"
type: "str"
activemq_configure_firewalld:
default: false
description: "Whether to install and configure firewalld"
type: "bool"
activemq_shared_storage:
default: false
description: "Use shared filesystem directory for storage"
type: "bool"
activemq_shared_storage_path:
default: "{{ activemq_dest }}/{{ activemq_instance_name }}/data/shared"
description: "Absolute path of shared directory"
type: "str"
activemq_shared_storage_mounted:
default: true
description: "Whether the systemd unit must require a mounted path (only when using shared storage)"
type: "bool"
activemq_name:
description: 'Human friendly name for service'
default: "Apache ActiveMQ"
type: "str"
activemq_service_name:
description: "Systemd unit name"
default: "activemq"
type: "str"
activemq_paging_directory:
description: 'The directory to store paged messages in'
default: 'data/paging'
type: "str"
activemq_bindings_directory:
description: 'The folder in use for the bindings folder'
default: 'data/bindings'
type: "str"
activemq_journal_directory:
description: 'The directory to store the journal files in'
default: 'data/journal'
type: "str"
activemq_large_messages_directory:
description: 'The directory to store large messages'
default: 'data/largemessages'
type: "str"
activemq_journal_datasync:
description: 'Whether to use msync/fsync on journal operations'
default: true
type: 'bool'
activemq_data_directory:
description: "The activemq data directory path"
default: "{{ activemq_shared_storage_path if activemq_shared_storage else activemq_dest + '/' + activemq_instance_name + '/data' }}"
type: 'str'
activemq_uninstall_skip_user:
description: 'Whether to skip user/group account deletion'
default: false
type: 'bool'
activemq_uninstall_skip_zipfile:
description: 'Whether to skip installation zipfile deletion'
default: false
type: 'bool'
activemq_uninstall_skip_artemis:
description: 'Whether to skip artemis directory deletion'
default: false
type: 'bool'
downstream:
options:
amq_broker_version:
default: "7.12.0"
description: "Red Hat AMQ Broker version"
type: "str"
amq_broker_enable:
default: true
description: "Enable installation of Red Hat AMQ Broker"
type: "bool"
amq_broker_archive:
default: "amq-broker-{{ amq_broker_version }}-bin.zip"
description: "Red Hat AMQ Broker install archive filename"
type: "str"
amq_broker_installdir:
default: "{{ amq_broker_dest }}/amq-broker-{{ amq_broker_version }}"
description: "Red Hat AMQ Broker installation path"
type: "str"
amq_broker_dest:
default: "/opt/amq"
description: "Root installation directory"
type: "str"
amq_broker_name:
description: "Human friendly name for service"
default: "Red Hat AMQ Broker"
type: "str"
amq_broker_service_name:
description: "Systemd unit name"
default: "amq_broker"
type: "str"
Loading