From 949b04eb5db6c2efe0ea99dddae21850f2babccd Mon Sep 17 00:00:00 2001 From: "Larry Smith Jr." Date: Thu, 21 Dec 2023 09:31:20 -0500 Subject: [PATCH] Fixed linting issues --- .ansible-lint | 2 ++ .gitignore | 26 +++++++++++++++-- handlers/main.yml | 2 +- meta/main.yml | 21 ++++---------- molecule/centos7/verify.yml | 2 +- molecule/centos8/verify.yml | 2 +- molecule/debian10/verify.yml | 2 +- molecule/debian8/verify.yml | 2 +- molecule/debian9/verify.yml | 2 +- molecule/fedora/verify.yml | 2 +- molecule/shared/converge.yml | 2 +- molecule/shared/prepare.yml | 9 ++++++ molecule/shared/verify.yml | 2 +- molecule/ubuntu1604/verify.yml | 2 +- molecule/ubuntu1804/verify.yml | 2 +- molecule/ubuntu2004/converge.yml | 2 +- molecule/ubuntu2004/verify.yml | 2 +- playbook.yml | 2 +- tasks/config.yml | 4 +-- tasks/debian.yml | 18 ++++++------ tasks/fedora.yml | 13 +++++---- tasks/main.yml | 29 +++++++++++------- tasks/rabbitmq_clustering.yml | 50 ++++++++++++++++---------------- tasks/rabbitmq_config.yml | 19 ++++++------ tasks/rabbitmq_ha_config.yml | 2 +- tasks/rabbitmq_users.yml | 24 +++++++-------- tasks/rabbitmq_vhosts.yml | 10 +++---- tasks/redhat.yml | 13 +++++---- 28 files changed, 151 insertions(+), 117 deletions(-) create mode 100644 .ansible-lint create mode 100644 molecule/shared/prepare.yml diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..a3119a8 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,2 @@ +skip_list: +- name[casing] diff --git a/.gitignore b/.gitignore index 738f238..af3fdb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,25 @@ -venv/ +!* + +### Ansible +.cache/ + +### VirtualEnv ### +# Virtualenv .venv/ -poetry.lock +venv/ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide diff --git a/handlers/main.yml b/handlers/main.yml index c727c75..e8816b7 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,7 +1,7 @@ --- # handlers file for ansible-rabbitmq - name: restart rabbitmq-server - service: + ansible.builtin.service: name: rabbitmq-server state: restarted become: true diff --git a/meta/main.yml b/meta/main.yml index 5492745..973f0ed 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -3,33 +3,22 @@ galaxy_info: author: Larry Smith Jr. description: Ansible role to install/configure RabbitMQ license: MIT - min_ansible_version: 1.2 + min_ansible_version: "1.2" role_name: rabbitmq namespace: mrlesmithjr platforms: - name: EL versions: - - 8 + - all - name: Fedora versions: - # - 22 - # - 23 - - 24 - - 25 - - 26 - - 27 - - 28 - - 29 + - all - name: Ubuntu versions: - - focal - - bionic - # - trusty - # - xenial + - all - name: Debian versions: - - buster - - stretch + - all galaxy_tags: - clustering - system diff --git a/molecule/centos7/verify.yml b/molecule/centos7/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/centos7/verify.yml +++ b/molecule/centos7/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/centos8/verify.yml b/molecule/centos8/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/centos8/verify.yml +++ b/molecule/centos8/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/debian10/verify.yml b/molecule/debian10/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/debian10/verify.yml +++ b/molecule/debian10/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/debian8/verify.yml b/molecule/debian8/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/debian8/verify.yml +++ b/molecule/debian8/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/debian9/verify.yml b/molecule/debian9/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/debian9/verify.yml +++ b/molecule/debian9/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/fedora/verify.yml b/molecule/fedora/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/fedora/verify.yml +++ b/molecule/fedora/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/shared/converge.yml b/molecule/shared/converge.yml index 265cb67..1a4bc3d 100644 --- a/molecule/shared/converge.yml +++ b/molecule/shared/converge.yml @@ -3,5 +3,5 @@ hosts: all tasks: - name: Include ansible-rabbitmq - include_role: + ansible.builtin.include_role: name: ansible-rabbitmq diff --git a/molecule/shared/prepare.yml b/molecule/shared/prepare.yml new file mode 100644 index 0000000..a2ac59e --- /dev/null +++ b/molecule/shared/prepare.yml @@ -0,0 +1,9 @@ +--- +- name: Prepare hosts for testing + hosts: all + tasks: + - name: Update Apt Cache + ansible.builtin.apt: + update_cache: true + become: true + when: ansible_os_family == "Debian" diff --git a/molecule/shared/verify.yml b/molecule/shared/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/shared/verify.yml +++ b/molecule/shared/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/ubuntu1604/verify.yml b/molecule/ubuntu1604/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/ubuntu1604/verify.yml +++ b/molecule/ubuntu1604/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/ubuntu1804/verify.yml b/molecule/ubuntu1804/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/ubuntu1804/verify.yml +++ b/molecule/ubuntu1804/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/molecule/ubuntu2004/converge.yml b/molecule/ubuntu2004/converge.yml index b2cea09..c7a8435 100644 --- a/molecule/ubuntu2004/converge.yml +++ b/molecule/ubuntu2004/converge.yml @@ -6,5 +6,5 @@ rabbitmq_debian_repo: "deb https://dl.bintray.com/rabbitmq-erlang/debian {{ ansible_distribution_release }} erlang-22.x" tasks: - name: Include ansible-rabbitmq - include_role: + ansible.builtin.include_role: name: ansible-rabbitmq diff --git a/molecule/ubuntu2004/verify.yml b/molecule/ubuntu2004/verify.yml index a82dd6f..86afba4 100644 --- a/molecule/ubuntu2004/verify.yml +++ b/molecule/ubuntu2004/verify.yml @@ -5,5 +5,5 @@ hosts: all tasks: - name: Example assertion - assert: + ansible.builtin.assert: that: true diff --git a/playbook.yml b/playbook.yml index 6387b53..0a20a39 100644 --- a/playbook.yml +++ b/playbook.yml @@ -3,5 +3,5 @@ hosts: all tasks: - name: Include ansible-rabbitmq - include_role: + ansible.builtin.include_role: name: ansible-rabbitmq diff --git a/tasks/config.yml b/tasks/config.yml index a738aa3..e11146c 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -1,6 +1,6 @@ --- - name: config | Configuring RabbitMQ - template: + ansible.builtin.template: src: "{{ rabbitmq_config_file }}" dest: "/etc/rabbitmq/rabbitmq.config" mode: u=rw,g=r,o=r @@ -8,7 +8,7 @@ notify: "restart rabbitmq-server" - name: config | Configuring RabbitMQ environemnt - template: + ansible.builtin.template: src: "{{ rabbitmq_config_env_file }}" dest: "/etc/rabbitmq/rabbitmq-env.conf" mode: u=rw,g=r,o=r diff --git a/tasks/debian.yml b/tasks/debian.yml index 10ed5d9..c27be9f 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml @@ -1,6 +1,6 @@ --- - name: debian | Adding Pre-Reqs - apt: + ansible.builtin.apt: name: - gnupg2 - apt-transport-https @@ -11,7 +11,7 @@ until: result is successful - name: debian | adding RabbitMQ repo public GPG key to the apt repo - apt_key: + ansible.builtin.apt_key: url: "{{ rabbitmq_debian_repo_key }}" state: present become: true @@ -19,7 +19,7 @@ until: result is successful - name: debian | adding RabbitMQ team public GPG key to the apt repo - apt_key: + ansible.builtin.apt_key: keyserver: keys.openpgp.org id: "{{ rabbitmq_debian_team_key }}" state: present @@ -28,7 +28,7 @@ until: result is successful - name: debian | adding RabbitMQ repo - apt_repository: + ansible.builtin.apt_repository: repo: "{{ rabbitmq_debian_repo }}" state: present become: true @@ -36,7 +36,7 @@ until: result is successful - name: debian | adding RabbitMQ relang repo public GPG key to the apt repo - apt_key: + ansible.builtin.apt_key: url: "{{ rabbitmq_debian_erlang_repo_key }}" state: present become: true @@ -44,23 +44,23 @@ until: result is successful - name: debian | add Rabbitmq erlang repo - apt_repository: + ansible.builtin.apt_repository: repo: "{{ rabbitmq_debian_erlang_repo }}" state: present become: true when: rabbitmq_debian_erlang_from_rabbit - name: debian | installing RabbitMQ server - apt: + ansible.builtin.apt: name: - - rabbitmq-server{{ (rabbitmq_debian_version_defined and rabbitmq_debian_version is defined) | ternary(['=',rabbitmq_debian_version] | join(''),'') }} + - rabbitmq-server{{ (rabbitmq_debian_version_defined and rabbitmq_debian_version is defined) | ternary(['=', rabbitmq_debian_version] | join(''), '') }} state: present become: true register: result until: result is successful - name: debian | ensuring that the RabbitMQ service is running - service: + ansible.builtin.service: name: rabbitmq-server state: started enabled: yes diff --git a/tasks/fedora.yml b/tasks/fedora.yml index 54a5c1e..b416c2c 100644 --- a/tasks/fedora.yml +++ b/tasks/fedora.yml @@ -1,6 +1,6 @@ --- - name: fedora | installing pre-reqs - dnf: + ansible.builtin.dnf: name: ['wget'] state: present become: true @@ -8,7 +8,7 @@ until: result is successful - name: fedora | installing erlang - dnf: + ansible.builtin.dnf: name: ['erlang'] state: present become: true @@ -16,7 +16,7 @@ until: result is successful - name: fedora | adding RabbitMQ public GPG key - rpm_key: + ansible.builtin.rpm_key: key: "{{ rabbitmq_redhat_repo_key }}" state: present become: true @@ -24,13 +24,14 @@ until: result is successful - name: fedora | downloading RabbitMQ - get_url: + ansible.builtin.get_url: url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}" dest: "/opt/{{ rabbitmq_redhat_package }}" + mode: u=rw,g=r,o=r become: true - name: fedora | installing RabbitMQ - dnf: + ansible.builtin.dnf: name: "/opt/{{ rabbitmq_redhat_package }}" state: present become: true @@ -38,7 +39,7 @@ until: result is successful - name: fedora | starting and enabling RabbitMQ service - service: + ansible.builtin.service: name: rabbitmq-server state: started enabled: true diff --git a/tasks/main.yml b/tasks/main.yml index dbad05b..ed6e83b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,41 +1,50 @@ --- # tasks file for ansible-rabbitmq -- include: debian.yml +- name: Include Debian tasks + ansible.builtin.include_tasks: debian.yml when: ansible_os_family == "Debian" -- include: redhat.yml +- name: Include RedHat tasks + ansible.builtin.include_tasks: redhat.yml when: > ansible_distribution == "CentOS" or ansible_distribution == "Red Hat Enterprise Linux" or ansible_distribution == "OracleLinux" -- include: fedora.yml +- name: Include Fedora tasks + ansible.builtin.include_tasks: fedora.yml when: ansible_distribution == "Fedora" -- include: rabbitmq_plugins.yml +- name: Manage RabbitMQ plugins + ansible.builtin.include_tasks: rabbitmq_plugins.yml when: rabbitmq_plugins is defined -- include: config.yml +- name: Configure RabbitMQ + ansible.builtin.include_tasks: config.yml when: rabbitmq_config_service - name: checking to see if already clustered - stat: + ansible.builtin.stat: path: /etc/rabbitmq/clustered become: true register: clustered -- include: rabbitmq_clustering.yml +- name: Manage RabbitMQ clustering + ansible.builtin.include_tasks: rabbitmq_clustering.yml when: > rabbitmq_enable_clustering and not clustered['stat']['exists'] -- include: rabbitmq_vhosts.yml +- name: Manage RabbitMQ virtual hosts + ansible.builtin.include_tasks: rabbitmq_vhosts.yml when: rabbitmq_extra_vhosts is defined -- include: rabbitmq_config.yml +- name: Configure RabbitMQ + ansible.builtin.include_tasks: rabbitmq_config.yml when: > rabbitmq_enable_clustering and rabbitmq_config is defined -- include: rabbitmq_users.yml +- name: Manage RabbitMQ users + ansible.builtin.include_tasks: rabbitmq_users.yml when: rabbitmq_users is defined diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml index c600828..1d14b6a 100644 --- a/tasks/rabbitmq_clustering.yml +++ b/tasks/rabbitmq_clustering.yml @@ -1,33 +1,33 @@ --- -- name: rabbitmq_clustering | stopping rabbitmq app - command: rabbitmqctl stop_app +- name: rabbitmq_clustering | stopping rabbitmq app # noqa no-changed-when + ansible.builtin.command: rabbitmqctl stop_app become: true when: inventory_hostname != rabbitmq_master -- name: rabbitmq_clustering | resetting rabbitmq app - command: rabbitmqctl reset +- name: rabbitmq_clustering | resetting rabbitmq app # noqa no-changed-when + ansible.builtin.command: rabbitmqctl reset become: true when: inventory_hostname != rabbitmq_master - name: rabbitmq_clustering | stopping rabbitmq-server - service: + ansible.builtin.service: name: rabbitmq-server state: stopped become: true -- name: rabbitmq_clustering | Capturing Erlang Cookie On Master - command: "cat {{ rabbitmq_erlang_cookie_file }}" +- name: rabbitmq_clustering | Capturing Erlang Cookie On Master # noqa no-changed-when + ansible.builtin.command: "cat {{ rabbitmq_erlang_cookie_file }}" become: true register: "rabbitmq_erlang_cookie" when: inventory_hostname == rabbitmq_master - name: rabbitmq_clustering | Setting Erlang Cookie Of Master on Non-Master - set_fact: + ansible.builtin.set_fact: rabbitmq_erlang_cookie: "{{ hostvars[rabbitmq_master]['rabbitmq_erlang_cookie']['stdout'] }}" when: inventory_hostname != rabbitmq_master - name: rabbitmq_clustering | copy erlang cookie - template: + ansible.builtin.template: src: erlang.cookie.j2 dest: "{{ rabbitmq_erlang_cookie_file }}" owner: rabbitmq @@ -39,53 +39,53 @@ when: inventory_hostname != rabbitmq_master - name: rabbitmq_clustering | restarting rabbitmq-server on master - service: + ansible.builtin.service: name: rabbitmq-server state: restarted become: true when: inventory_hostname == rabbitmq_master -- name: rabbitmq_clustering | starting rabbitmq app on master - command: rabbitmqctl start_app +- name: rabbitmq_clustering | starting rabbitmq app on master # noqa no-changed-when + ansible.builtin.command: rabbitmqctl start_app register: cluster_master become: true when: inventory_hostname == rabbitmq_master -- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes - shell: pkill -u rabbitmq || true +- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes # noqa no-changed-when + ansible.builtin.shell: pkill -u rabbitmq || true become: true when: inventory_hostname != rabbitmq_master - name: rabbitmq_clustering | restarting rabbitmq-server - service: + ansible.builtin.service: name: rabbitmq-server state: restarted become: true when: inventory_hostname != rabbitmq_master -- name: rabbitmq_clustering | stopping rabbitmq app - command: rabbitmqctl stop_app +- name: rabbitmq_clustering | stopping rabbitmq app # noqa no-changed-when + ansible.builtin.command: rabbitmqctl stop_app become: true when: inventory_hostname != rabbitmq_master -- name: rabbitmq_clustering | resetting rabbitmq app - command: rabbitmqctl reset +- name: rabbitmq_clustering | resetting rabbitmq app # noqa no-changed-when + ansible.builtin.command: rabbitmqctl reset become: true when: inventory_hostname != rabbitmq_master -- name: rabbitmq_clustering | joining rabbitmq cluster - command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}" +- name: rabbitmq_clustering | joining rabbitmq cluster # noqa no-changed-when + ansible.builtin.command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}" register: cluster_joined become: true when: inventory_hostname != rabbitmq_master -- name: rabbitmq_clustering | starting rabbitmq app - command: rabbitmqctl start_app +- name: rabbitmq_clustering | starting rabbitmq app # noqa no-changed-when + ansible.builtin.command: rabbitmqctl start_app become: true when: inventory_hostname != rabbitmq_master -- name: rabbitmq_clustering | marking as clustered # noqa 503 - file: +- name: rabbitmq_clustering | marking as clustered # noqa no-handler + ansible.builtin.file: path: /etc/rabbitmq/clustered state: touch mode: u=rw,g=r,o=r diff --git a/tasks/rabbitmq_config.yml b/tasks/rabbitmq_config.yml index 773accc..60dd66e 100644 --- a/tasks/rabbitmq_config.yml +++ b/tasks/rabbitmq_config.yml @@ -1,11 +1,11 @@ --- - name: rabbitmq_config | checking if rabbitmqadmin is installed - stat: + ansible.builtin.stat: path: /usr/sbin/rabbitmqadmin register: rabbitmqadmin_check - name: rabbit_config | Installing rabbitMQ admin - get_url: + ansible.builtin.get_url: url: http://guest:guest@localhost:15672/cli/rabbitmqadmin dest: /usr/sbin/rabbitmqadmin mode: u=rwx,g=rw,o=rw @@ -13,16 +13,16 @@ notify: restart rabbitmq-server when: not rabbitmqadmin_check['stat']['exists'] -- name: rabbitmq_config | creating exchange(s) - command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }} +- name: rabbitmq_config | creating exchange(s) # noqa no-changed-when + ansible.builtin.command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }} run_once: true delegate_to: "{{ rabbitmq_master }}" become: true with_items: "{{ rabbitmq_config }}" when: item['exchange_name'] is defined -- name: rabbitmq_config | creating queue(s) - command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }} queue_type={{ item['queue_type'] | default('classic') }} +- name: rabbitmq_config | creating queue(s) # noqa no-changed-when + ansible.builtin.command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable'] | lower }} --vhost={{ item['vhost'] | default('/') }} queue_type={{ item['queue_type'] | default('classic') }} run_once: true delegate_to: "{{ rabbitmq_master }}" become: true @@ -30,11 +30,12 @@ - item['queue_name'] is defined with_items: "{{ rabbitmq_config }}" -- include: rabbitmq_ha_config.yml +- name: rabbitmq_config | Manage RabbitMQ HA + ansible.builtin.include_tasks: rabbitmq_ha_config.yml when: rabbitmq_config_ha -- name: rabbitmq_config | creating binding(s) - command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }} --vhost={{ item['vhost'] | default('/') }} # noqa 204 +- name: rabbitmq_config | creating binding(s) # noqa no-changed-when + ansible.builtin.command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }} --vhost={{ item['vhost'] | default('/') }} # noqa 204 run_once: true delegate_to: "{{ rabbitmq_master }}" become: true diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml index f0e48ef..26783f3 100644 --- a/tasks/rabbitmq_ha_config.yml +++ b/tasks/rabbitmq_ha_config.yml @@ -8,7 +8,7 @@ state: present vars: policy_vhost: "{{ item.vhost | default('/') }}" - policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}" + policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern | default(''), item.queue_name | default('')) }}" run_once: true delegate_to: "{{ rabbitmq_master }}" become: true diff --git a/tasks/rabbitmq_users.yml b/tasks/rabbitmq_users.yml index 691cbd3..1a52801 100644 --- a/tasks/rabbitmq_users.yml +++ b/tasks/rabbitmq_users.yml @@ -3,12 +3,12 @@ rabbitmq_user: name: "{{ item['name'] }}" password: "{{ item['password'] }}" - vhost: "{{ item['vhost']|default(omit) }}" - configure_priv: "{{ item['configure_priv']|default(omit) }}" - read_priv: "{{ item['read_priv']|default(omit) }}" - write_priv: "{{ item['write_priv']|default(omit) }}" - tags: "{{ item['tags']|default(omit) }}" - permissions: "{{ item['permissions']|default(omit) }}" + vhost: "{{ item['vhost'] | default(omit) }}" + configure_priv: "{{ item['configure_priv'] | default(omit) }}" + read_priv: "{{ item['read_priv'] | default(omit) }}" + write_priv: "{{ item['write_priv'] | default(omit) }}" + tags: "{{ item['tags'] | default(omit) }}" + permissions: "{{ item['permissions'] | default(omit) }}" state: present become: true loop: "{{ rabbitmq_users }}" @@ -23,12 +23,12 @@ rabbitmq_user: name: "{{ item['name'] }}" password: "{{ item['password'] }}" - vhost: "{{ item['vhost']|default(omit) }}" - configure_priv: "{{ item['configure_priv']|default(omit) }}" - read_priv: "{{ item['read_priv']|default(omit) }}" - write_priv: "{{ item['write_priv']|default(omit) }}" - tags: "{{ item['tags']|default(omit) }}" - permissions: "{{ item['permissions']|default(omit) }}" + vhost: "{{ item['vhost'] | default(omit) }}" + configure_priv: "{{ item['configure_priv'] | default(omit) }}" + read_priv: "{{ item['read_priv'] | default(omit) }}" + write_priv: "{{ item['write_priv'] | default(omit) }}" + tags: "{{ item['tags'] | default(omit) }}" + permissions: "{{ item['permissions'] | default(omit) }}" state: present run_once: yes delegate_to: "{{ rabbitmq_master }}" diff --git a/tasks/rabbitmq_vhosts.yml b/tasks/rabbitmq_vhosts.yml index 11fbba1..7e311d2 100644 --- a/tasks/rabbitmq_vhosts.yml +++ b/tasks/rabbitmq_vhosts.yml @@ -8,19 +8,19 @@ run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" register: rabbitmq_created_vhosts -- name: rabbitmq_extra_vhosts | Check guest administrator is present # noqa 503 - command: rabbitmqctl -q list_users +- name: rabbitmq_extra_vhosts | Check guest administrator is present # noqa no-handler + ansible.builtin.command: rabbitmqctl -q list_users become: true run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" when: rabbitmq_created_vhosts.changed changed_when: false register: rabbitmq_existing_users -- name: rabbitmq_extra_vhosts | Give access to new vhosts to guest administrator - command: "rabbitmqctl -q set_permissions -p {{ item['name'] }} guest '.*' '.*' '.*'" +- name: rabbitmq_extra_vhosts | Give access to new vhosts to guest administrator # noqa no-changed-when + ansible.builtin.command: "rabbitmqctl -q set_permissions -p {{ item['name'] }} guest '.*' '.*' '.*'" become: true run_once: "{{ rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering }}" - with_items: "{{ rabbitmq_created_vhosts.results|selectattr('changed')|list }}" + with_items: "{{ rabbitmq_created_vhosts.results | selectattr('changed') | list }}" when: - item['state'] == 'present' - rabbitmq_existing_users.stdout_lines | map('regex_search', '^guest\\s\\[.*administrator.*\\]$') | list | difference([None]) | length > 0 diff --git a/tasks/redhat.yml b/tasks/redhat.yml index 2287429..fd4fa2c 100644 --- a/tasks/redhat.yml +++ b/tasks/redhat.yml @@ -1,6 +1,6 @@ --- - name: redhat | installing pre-reqs - yum: + ansible.builtin.yum: name: ['epel-release', 'wget'] state: present become: true @@ -8,7 +8,7 @@ until: result is successful - name: redhat | installing erlang - yum: + ansible.builtin.yum: name: erlang state: present become: true @@ -16,7 +16,7 @@ until: result is successful - name: redhat | adding RabbitMQ public GPG key - rpm_key: + ansible.builtin.rpm_key: key: "{{ rabbitmq_redhat_repo_key }}" state: present become: true @@ -24,13 +24,14 @@ until: result is successful - name: redhat | downloading RabbitMQ - get_url: + ansible.builtin.get_url: url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}" dest: "/opt/{{ rabbitmq_redhat_package }}" + mode: u=rw,g=r,o=r become: true - name: redhat | installing RabbitMQ - yum: + ansible.builtin.yum: name: "/opt/{{ rabbitmq_redhat_package }}" state: present become: true @@ -38,7 +39,7 @@ until: result is successful - name: redhat | starting and enabling RabbitMQ service - service: + ansible.builtin.service: name: rabbitmq-server state: started enabled: yes