Skip to content

Commit

Permalink
Ansible Lint Fixes (#58)
Browse files Browse the repository at this point in the history
* fix all ansible-lint errors

* update lint based on recent commits

* linux (rhel) lint fixes

* delete unused playbook testmod.yml

* update windows script on winstall.md and remove hardcoded download path for AIX

---------

Co-authored-by: Benjamin Brunyee <benjamin.brunyee@ibm.com>
  • Loading branch information
bimsara-yasitha01 and Benjamin Brunyee committed Jul 20, 2023
1 parent 71801a9 commit 7243a4a
Show file tree
Hide file tree
Showing 45 changed files with 764 additions and 738 deletions.
14 changes: 8 additions & 6 deletions .ansible-lint
@@ -1,4 +1,5 @@
profile: null # min, basic, moderate,safety, shared, production
---
profile: # min, basic, moderate,safety, shared, production

# Allows dumping of results in SARIF format
# sarif_file: result.sarif
Expand All @@ -7,6 +8,7 @@ profile: null # min, basic, moderate,safety, shared, production
# and not relative to the CWD of execution. CLI arguments passed to the --exclude
# option are parsed relative to the CWD of execution.
exclude_paths:
- .ansible-lint
- .cache/ # implicit unless exclude_paths is defined in config
- .github/
# - test/fixtures/formatting-before/
Expand All @@ -23,17 +25,17 @@ mock_modules:
# - fake_namespace.fake_collection.fake_module
# - fake_namespace.fake_collection.fake_module.fake_submodule
# mock_roles:
# - mocked_role
# - author.role_name # old standalone galaxy role
# - fake_namespace.fake_collection.fake_role # role within a collection
# - mocked_role
# - author.role_name # old standalone galaxy role
# - fake_namespace.fake_collection.fake_role # role within a collection

# Enable checking of loop variable prefixes in roles
loop_var_prefix: "^(__|{role}_)"
# loop_var_prefix: ^(__|{role}_)

# Enforce variable names to follow pattern below, in addition to Ansible own
# requirements, like avoiding python identifiers. To disable add `var-naming`
# to skip_list.
var_naming_pattern: "^[a-z_][a-z0-9_]*$"
var_naming_pattern: ^[a-z_][a-z0-9_]*$

use_default_rules: true
# Load custom rules from this specific folder
Expand Down
11 changes: 5 additions & 6 deletions README.md
Expand Up @@ -61,14 +61,13 @@ The playbooks and roles in this collection carry out an installation of IBM MQ A
roles:
- role: setupusers
vars:
appUid: 909
appGid: 909
mqmHome: /home/mqm
mqmProfile: .profile
app_uid: 909
app_gid: 909
mqm_home: /home/mqm
mqm_profile: .profile
- role: downloadmq
vars:
version: 930
- role: installmq-linux
```
`mq-setup.yml` - this playbook sets up IBM MQ using the 'mqm' user

Expand Down Expand Up @@ -100,7 +99,7 @@ The playbooks and roles in this collection carry out an installation of IBM MQ A

`downloadmq` - downloads and unzips the appropriate MQ package based on the target platform to `/var/MQServer` on the target machine. The MQ version to be installed can be specified when calling this role.

`installmq-linux` - handles platform-specific installation steps, where Ubuntu machines carry out a Debian installation and RedHat machines carry out an RPM installation. Core MQ components are installed as default, however further components and languages can be be added by uncommenting packages within the `package_files` list in `/roles/installmq-linux/tasks/main.yml`.
`installmq` - handles platform-specific installation steps, where Ubuntu machines carry out a Debian installation and RedHat machines carry out an RPM installation. Core MQ components are installed as default, however further components and languages can be be added by uncommenting packages within the `package_files` list in `/roles/installmq/tasks/main.yml`:

##### *Note*: For Ubuntu, dependencies are sensitive to the order of regex-matched packages in the `with_items` attribute of the above task.

Expand Down
2 changes: 1 addition & 1 deletion WINSTALL.md
Expand Up @@ -12,7 +12,7 @@ Our collection now also allows you to automate the download and install of IBM M
- Have PowerShell 3.0 or newer and at least .NET 4.0
- Have WinRM configured to have a listener created and activated.

For more information on how to set up your Windows host, please refer to [Ansible documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_setup.html#winrm-listener). You can also run a [_Configure Remoting for Ansible_](https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1) script to set up your Windows machine and turn on WinRM. For more details of the script, refer to the official Ansible blog [here](https://www.ansible.com/blog/connecting-to-a-windows-host).
For more information on how to set up your Windows host, please refer to [Ansible documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_setup.html#winrm-listener). You can also run a [_Configure Remoting for Ansible_](https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1) script to set up your Windows machine and turn on WinRM. For more details of the script, refer to the official Ansible blog [here](https://www.ansible.com/blog/connecting-to-a-windows-host).

2. Set up your local machine

Expand Down
1 change: 1 addition & 0 deletions ansible_collections/ibm/ibmmq/ibmmq.yml
@@ -1,3 +1,4 @@
---
- name: Install and setup IBM MQ
hosts: ['servers']

Expand Down
19 changes: 10 additions & 9 deletions ansible_collections/ibm/ibmmq/mq-install.yml
@@ -1,19 +1,20 @@
- hosts: "{{ ansible_play_batch }}"
---
- hosts: "{{ ansible_play_batch }}"
serial: 1
become: yes
become: true
environment:
PATH: /opt/mqm/bin:{{ ansible_env.PATH }}

roles:
roles:
- role: setupusers
vars:
appUid: 909
app_uid: 909
gid: 909
appGid: 909
mqmHome: /home/mqm
mqmProfile: .profile
app_gid: 909
mqm_home: /home/mqm
mqm_profile: .profile
- role: downloadmq
vars:
version: 930
downloadURL: "https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/"
- role: installmq
downloadURL: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
- role: installmq
32 changes: 16 additions & 16 deletions ansible_collections/ibm/ibmmq/mq-setup.yml
@@ -1,35 +1,35 @@
---
- hosts: "{{ ansible_play_hosts }}"
serial: 1
become: yes
become_user: mqm
become: true
become_user: mqm
environment:
PATH: /opt/mqm/bin:{{ ansible_env.PATH }}

roles:
roles:
- getconfig
- setupconsole
- startconsole

tasks:

- name: Create a queue manager
queue_manager:
qmname:
- 'QM1'
- 'QM2'
state: 'present'
qmname:
- QM1
- QM2
state: present

- name: Start a queue manager
queue_manager:
qmname:
- 'QM1'
- 'QM2'
state: 'running'
- QM1
- QM2
state: running

- name: Run MQSC File
queue_manager:
qmname:
- 'QM1'
- 'QM2'
state: 'running'
mqsc_file: '/var/mqm/dev-config.mqsc'
- QM1
- QM2
state: running
mqsc_file: /var/mqm/dev-config.mqsc
@@ -1,8 +1,6 @@
---

- name: Download MQ Advanced for Developers
copy:
src : /Users/moalatoum/Downloads/mq-ansible/9.3.0.0-IBM-MQTRIAL-AixPPC64.tar.Z
copy:
src: /Users/<your-user>/Downloads/9.3.0.0-IBM-MQTRIAL-AixPPC64.tar.Z
dest: ~/tmp/


mode: "0644"
@@ -1,25 +1,25 @@
---

- name: Set filename of zip if target host is Ubuntu
set_fact:
zipFile: "mqadv_dev{{ version }}_ubuntu_x86-64.tar.gz"
zip_file: mqadv_dev{{ version }}_ubuntu_x86-64.tar.gz
when: ansible_distribution == 'Ubuntu'

- name: Set filename of zip if target host is RedHat
set_fact:
zipFile: "mqadv_dev{{ version }}_linux_x86-64.tar.gz"
zip_file: mqadv_dev{{ version }}_linux_x86-64.tar.gz
when: ansible_distribution == 'RedHat'

- name: Download MQ Advanced for Developers
get_url:
url: "{{ downloadURL }}{{ zipFile }}"
url: "{{ downloadURL }}{{ zip_file }}"
dest: /var/mq.tar.gz
force: no
force: false
mode: "0644"
tags: download

- name: Extract MQ fom TAR
unarchive:
src: /var/mq.tar.gz
remote_src: yes
remote_src: true
dest: /var
tags: download
tags: download
@@ -1,22 +1,21 @@
---

- name: Set filename of zip if target host is Windows
set_fact:
zipFile: "mqadv_dev{{ version }}_windows.zip"
zipFile: mqadv_dev{{ version }}_windows.zip
when: ansible_os_family == 'Windows'

- name: Download MQ Advanced for Developers on Windows
ansible.windows.win_get_url:
url: "{{ downloadURL }}{{ zipFile }}"
dest: '{{ directory }}\mq.zip'
force: no
dest: "{{ directory }}\\mq.zip"
force: false
tags: download
when: ansible_os_family == 'Windows'

- name: Unzip MQ on Windows
community.windows.win_unzip:
src: '{{ directory }}\mq.zip'
remote_src: yes
dest: '{{ directory }}\mq-install'
src: "{{ directory }}\\mq.zip"
remote_src: true
dest: "{{ directory }}\\mq-install"
tags: download
when: ansible_os_family == 'Windows'
4 changes: 0 additions & 4 deletions ansible_collections/ibm/ibmmq/roles/downloadmq/tasks/main.yml
@@ -1,10 +1,6 @@
---

- name: Including the vars for this platform
include_vars: "{{ ansible_system }}_{{ role_name }}.yml"

- name: Including the task list for this platform
include_tasks: "{{ ansible_system }}_{{ role_name }}.yml"



@@ -1,3 +1,3 @@
---
version: 930
downloadURL: "https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/"
downloadURL: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
@@ -1,3 +1,3 @@
---
version: 930
downloadURL: "https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/"
downloadURL: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
@@ -1,3 +1,4 @@
---
version: 930
downloadURL: "https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/"
directory: C:\Users\Administrator
downloadURL: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/
directory: C:\Users\Administrator
@@ -1,7 +1,7 @@
---

- name: Copy developer config file to target
become: true
copy:
src: ../../../dev-config.mqsc
dest: "/tmp/dev-config.mqsc"
dest: /tmp/dev-config.mqsc
mode: "0644"
@@ -1,5 +1,6 @@

---
- name: Copy developer config file to target
copy:
src: ../../../dev-config.mqsc
dest: "/var/mqm"
dest: /var/mqm
mode: "0644"
4 changes: 0 additions & 4 deletions ansible_collections/ibm/ibmmq/roles/getconfig/tasks/main.yml
@@ -1,7 +1,3 @@
---

- name: Including the task list for this platform
include_tasks: "{{ ansible_system }}_{{ role_name }}.yml"



@@ -1,5 +1,4 @@
---

- name: Check if license status file exists
stat:
path: /tmp/MQServer/licensestatus.txt
Expand All @@ -12,35 +11,37 @@
# changed_when: not license_status.stat.exists

- name: Check if MQ is installed
shell: apt list | grep ibmmq
shell: set -o pipefail && apt list | grep ibmmq
changed_when: false
register: installed_mq_packages
failed_when:
- "'FAIL' in installed_mq_packages.stderr"

- name: Set MQ Packages Location
set_fact:
MQ_PACKAGES_LOCATION: "/tmp/MQServer"
mq_packages_location: /tmp/MQServer

- name: Check if IBM MQ is already installed
shell: dspmqver
command: dspmqver
changed_when: false
register: mq_installed
ignore_errors: yes
ignore_errors: true

- name: Run IBM MQ installation script if MQ is not installed
shell: |
./mq_install_script.sh
args:
chdir: "{{ MQ_PACKAGES_LOCATION }}"
chdir: "{{ mq_packages_location }}"
when: mq_installed.rc != 0
become: yes
become: true
become_user: root

- name: Install MQ Server
become: true
shell: |
installp -acgXd . all
args:
chdir: "/tmp/MQServer"
chdir: /tmp/MQServer
register: installed_mq_packages
changed_when: "'ibmmq' not in installed_mq_packages.stdout"

Expand All @@ -49,22 +50,26 @@
lineinfile:
dest: /etc/profile
state: present
line: '. /opt/mqm/bin/setmqenv -s'
line: . /opt/mqm/bin/setmqenv -s

- name: Cleanup after installation
become: true
command: echo "No cleanup required."
changed_when: False
changed_when: false

- name: Add the user to group mqm
become: true
changed_when: true
tags:
- skip_ansible_lint
shell: |
chuser groups=mqm ${SUDO_USER:-${USER}}
- name: Add the ansible ssh user to group mqm
become: true
changed_when: true
shell: |
chuser groups=mqm "{{ ansible_ssh_user }}"
- name: reset ssh connection
meta: reset_connection
- name: Reset ssh connection
meta: reset_connection

0 comments on commit 7243a4a

Please sign in to comment.