Skip to content

Commit

Permalink
Merge pull request #8 from ibm-messaging/enhancements-r2
Browse files Browse the repository at this point in the history
Enhancements r2 and fixing issues.
  • Loading branch information
marianavillarp authored Feb 14, 2023
2 parents e10fd81 + 97c2ff7 commit f7aeb06
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 77 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ The sample playbook [`ibmmq.yml`](ansible_collections/ibm/ibmmq/ibmmq.yml) insta
- On Mac:

```shell
export ANSIBLE_LIBRARY=${ANSIBLE_LIBRARY}:<PATH-TO>/ansible_mq/ansible_collections/ibm/ibmmq/library
export ANSIBLE_LIBRARY=${ANSIBLE_LIBRARY}:<PATH-TO>/mq-ansible/ansible_collections/ibm/ibmmq/library
```

- On Windows:

```shell
set ANSIBLE_LIBRARY=%ANSIBLE_LIBRARY%;<PATH-TO>/ansible_mq/ansible_collections/ibm/ibmmq/library
set ANSIBLE_LIBRARY=%ANSIBLE_LIBRARY%;<PATH-TO>/mq-ansible/ansible_collections/ibm/ibmmq/library
```

2. Run the following command to execute the tasks within the playbook:
```shell
ansible-playbook ./ibmmq.yml -i inventory.ini
ansible-playbook ./ibmmq.yml -i inventory.ini -e 'ibmMqLicence=accept'
```
- ##### *Note*: you can optionally add `-K` (uppercase) to the command, this will prompt the user to enter the sudo password for [YOUR_SSH_USER] on the target machine, you can omit if you have setup SSH keys

Expand Down Expand Up @@ -201,16 +201,20 @@ These playbooks test the functionality and performance of our roles and the queu

To run the test playbooks first:

1. make sure you are in the right directory
1. copy your `inventory.ini` file to the `tests/playbooks` directory
```shell
cp invenotry.ini tests/playbooks
```
2. go to the `tests/playbooks` directory
```shell
cd tests/playbooks
```
2. export the modules to your Ansible library
3. export the modules to your Ansible library
```shell
export ANSIBLE_LIBRARY=${ANSIBLE_LIBRARY}:<PATH-TO>/ansible_mq/ansible_collections/ibm/ibmmq/library
```
- ##### *Note*: change `<PATH-TO>` to your local directory path:
3. run all test playbooks with `python3 main.py`
4. run all test playbooks with `python3 main.py`

## License

Expand Down
4 changes: 3 additions & 1 deletion ansible_collections/ibm/ibmmq/mq-install.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- hosts: "{{ ansible_play_batch }}"
serial: 1
become: false
become: yes
environment:
PATH: /opt/mqm/bin:{{ ansible_env.PATH }}

Expand All @@ -9,5 +9,7 @@
vars:
appUid: 909
appGid: 909
mqmHome: /home/mqm
mqmProfile: .profile
- downloadmq
- installmq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

ibmMqLicence: "not accepted"
21 changes: 9 additions & 12 deletions ansible_collections/ibm/ibmmq/roles/installmq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
register: license_status

- name: Accept MQ license
become: true
shell: |
/tmp/MQServer/mqlicense.sh -accept > /tmp/MQServer/licensestatus.txt
/tmp/MQServer/mqlicense.sh -{{ ibmMqLicence}} > /tmp/MQServer/licensestatus.txt
changed_when: not license_status.stat.exists

- name: Check if MQ is installed
Expand All @@ -18,32 +17,30 @@
- "'FAIL' in installed_mq_packages.stderr"

- name: Create list file and run apt update again to update the apt cache
become: true
shell: |
MQ_PACKAGES_LOCATION=/tmp/MQServer
echo "deb [trusted=yes] file:$MQ_PACKAGES_LOCATION /" > /etc/apt/sources.list.d/mq-install.list
apt-get update
changed_when: 'installed_mq_packages.stdout_lines | string is not search("ibmmq")'

- name: Install MQ Server
become: true
shell: apt-get install -y "ibmmq-*"
changed_when: 'installed_mq_packages.stdout_lines | string is not search("ibmmq")'

- name: Set MQ environment variables through profile
become: yes
lineinfile:
dest: /etc/profile
state: present
line: '. /opt/mqm/bin/setmqenv -s'

- name: Delete .list file and run apt update again to clear the apt cache
become: true
shell: |
rm /etc/apt/sources.list.d/mq-install.list
apt-get update
changed_when: 'installed_mq_packages.stdout_lines | string is not search("ibmmq")'

- name: Install acl
apt:
state: latest
update_cache: true
pkg:
- acl
when: ansible_facts['distribution']=="Ubuntu"

- name: reset ssh connection
meta: reset_connection

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
appUid: 909
appGid: 909
mqmUid: 2001
mqmGid: 2001
mqmGid: 2001
mqmHome: /home/mqm
mqmProfile: .profile
mqmShell: /bin/bash
10 changes: 10 additions & 0 deletions ansible_collections/ibm/ibmmq/roles/setupusers/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@
name: mqm
uid: "{{ mqmUid }}"
group: mqm
home: "{{ mqmHome }}"
shell: "{{ mqmShell }}"

- name: Set MQ environment variables through profile
lineinfile:
dest: "{{ mqmHome }}/{{mqmProfile}}"
state: present
line: '. /opt/mqm/bin/setmqenv -s'

- name: Create an admin user
user:
name: mqadm
groups: mqm
append: yes
home: "{{ mqmHome }}"
shell: "{{ mqmShell }}"

- name: Add 'mqclient' group
become: true
Expand Down
39 changes: 0 additions & 39 deletions ansible_collections/ibm/ibmmq/tests/playbooks/ibmmq_travis.yml

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions ansible_collections/ibm/ibmmq/tests/playbooks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import subprocess
subprocess.run(['ansible-playbook', '--inventory', 'inventory.ini', 'test_install.yml'])
subprocess.run(['ansible-playbook', '--inventory', 'inventory.ini', 'setup_test.yml'])
subprocess.run(['ansible-playbook', '--inventory', 'inventory.ini', 'test_absent_qmgr.yml'])
subprocess.run(['ansible-playbook', '--inventory', 'inventory.ini', 'test_present_qmgr.yml'])
subprocess.run(['ansible-playbook', '--inventory', 'inventory.ini', 'test_running_qmgr.yml'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: test downloading and installing MQ
hosts: docker
hosts: all
become: true
environment:
PATH: /opt/mqm/bin:{{ ansible_env.PATH }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: test downloading and installing MQ
hosts: docker
hosts: all
become: false
environment:
PATH: /opt/mqm/bin:{{ ansible_env.PATH }}
Expand Down

0 comments on commit f7aeb06

Please sign in to comment.