diff options
author | Larry Smith Jr <mrlesmithjr@gmail.com> | 2018-12-20 01:50:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-20 01:50:27 -0500 |
commit | d58696271f166b50faa2705fdda6337c1ffb493c (patch) | |
tree | 031334f41175d9a4ddfc9c0769b911f775360f26 /tasks | |
parent | c760a03786a2247c14129dfd22c0e0fe1357f094 (diff) | |
parent | 8273b06f4eb706a6e52d9806c30660c9bd6707d1 (diff) | |
download | ansible-rabbitmq-d58696271f166b50faa2705fdda6337c1ffb493c.tar.gz ansible-rabbitmq-d58696271f166b50faa2705fdda6337c1ffb493c.tar.zst ansible-rabbitmq-d58696271f166b50faa2705fdda6337c1ffb493c.zip |
Merge pull request #20 from mrlesmithjr/refactoring-code
Refactoring code
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/debian.yml | 20 | ||||
-rw-r--r-- | tasks/fedora.yml | 18 | ||||
-rw-r--r-- | tasks/main.yml | 4 | ||||
-rw-r--r-- | tasks/rabbitmq_ha_config.yml | 17 | ||||
-rw-r--r-- | tasks/redhat.yml | 17 |
5 files changed, 49 insertions, 27 deletions
diff --git a/tasks/debian.yml b/tasks/debian.yml index f35bf55..0a6572e 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml | |||
@@ -1,21 +1,35 @@ | |||
1 | --- | 1 | --- |
2 | - name: debian | Adding Pre-Reqs | ||
3 | apt: | ||
4 | name: ['gnupg2'] | ||
5 | state: present | ||
6 | become: true | ||
7 | register: result | ||
8 | until: result is successful | ||
9 | |||
2 | - name: debian | adding RabbitMQ public GPG key to the apt repo | 10 | - name: debian | adding RabbitMQ public GPG key to the apt repo |
3 | apt_key: | 11 | apt_key: |
4 | url: "{{ rabbitmq_debian_repo_key }}" | 12 | url: "{{ rabbitmq_debian_repo_key }}" |
5 | state: present | 13 | state: present |
6 | become: true | 14 | become: true |
15 | register: result | ||
16 | until: result is successful | ||
7 | 17 | ||
8 | - name: debian | adding RabbitMQ repo | 18 | - name: debian | adding RabbitMQ repo |
9 | apt_repository: | 19 | apt_repository: |
10 | repo: "{{ rabbitmq_debian_repo }}" | 20 | repo: "{{ rabbitmq_debian_repo }}" |
11 | state: present | 21 | state: present |
12 | become: true | 22 | become: true |
23 | register: result | ||
24 | until: result is successful | ||
13 | 25 | ||
14 | - name: debian | add Rabbitmq erlang repo key | 26 | - name: debian | add Rabbitmq erlang repo key |
15 | apt_key: | 27 | apt_key: |
16 | url: https://bintray.com/user/downloadSubjectPublicKey?username=rabbitmq-erlang | 28 | url: https://bintray.com/user/downloadSubjectPublicKey?username=rabbitmq-erlang |
17 | state: present | 29 | state: present |
18 | become: true | 30 | become: true |
31 | register: result | ||
32 | until: result is successful | ||
19 | when: rabbitmq_debian_erlang_from_rabbit | 33 | when: rabbitmq_debian_erlang_from_rabbit |
20 | 34 | ||
21 | - name: debian | add Rabbitmq erlang repo | 35 | - name: debian | add Rabbitmq erlang repo |
@@ -27,11 +41,13 @@ | |||
27 | 41 | ||
28 | - name: debian | installing RabbitMQ server | 42 | - name: debian | installing RabbitMQ server |
29 | apt: | 43 | apt: |
30 | name: "{{ item }}" | 44 | name: ['rabbitmq-server'] |
31 | state: present | 45 | state: present |
32 | become: true | 46 | become: true |
47 | register: result | ||
48 | until: result is successful | ||
33 | with_items: | 49 | with_items: |
34 | - rabbitmq-server{{ (rabbitmq_debian_version is defined) | ternary(['=',rabbitmq_debian_version] | join(''),'')}} | 50 | - rabbitmq-server{{ (rabbitmq_debian_version is defined) | ternary(['=',rabbitmq_debian_version] | join(''),'') }} |
35 | 51 | ||
36 | - name: debian | enabling the RabbitMQ Management Console | 52 | - name: debian | enabling the RabbitMQ Management Console |
37 | rabbitmq_plugin: | 53 | rabbitmq_plugin: |
diff --git a/tasks/fedora.yml b/tasks/fedora.yml index 6ac9c03..b09ced0 100644 --- a/tasks/fedora.yml +++ b/tasks/fedora.yml | |||
@@ -1,23 +1,27 @@ | |||
1 | --- | 1 | --- |
2 | - name: fedora | installing pre-reqs | 2 | - name: fedora | installing pre-reqs |
3 | dnf: | 3 | dnf: |
4 | name: "{{ item }}" | 4 | name: ['wget'] |
5 | state: present | 5 | state: present |
6 | become: true | 6 | become: true |
7 | with_items: | 7 | register: result |
8 | - wget | 8 | until: result is successful |
9 | 9 | ||
10 | - name: fedora | installing erlang | 10 | - name: fedora | installing erlang |
11 | dnf: | 11 | dnf: |
12 | name: "erlang" | 12 | name: ['erlang'] |
13 | state: present | 13 | state: present |
14 | become: true | 14 | become: true |
15 | register: result | ||
16 | until: result is successful | ||
15 | 17 | ||
16 | - name: fedora | adding RabbitMQ public GPG key | 18 | - name: fedora | adding RabbitMQ public GPG key |
17 | rpm_key: | 19 | rpm_key: |
18 | key: "{{ rabbitmq_redhat_repo_key }}" | 20 | key: "{{ rabbitmq_redhat_repo_key }}" |
19 | state: present | 21 | state: present |
20 | become: true | 22 | become: true |
23 | register: result | ||
24 | until: result is successful | ||
21 | 25 | ||
22 | - name: fedora | downloading RabbitMQ | 26 | - name: fedora | downloading RabbitMQ |
23 | get_url: | 27 | get_url: |
@@ -30,12 +34,14 @@ | |||
30 | name: "/opt/{{ rabbitmq_redhat_package }}" | 34 | name: "/opt/{{ rabbitmq_redhat_package }}" |
31 | state: present | 35 | state: present |
32 | become: true | 36 | become: true |
37 | register: result | ||
38 | until: result is successful | ||
33 | 39 | ||
34 | - name: fedora | starting and enabling RabbitMQ service | 40 | - name: fedora | starting and enabling RabbitMQ service |
35 | service: | 41 | service: |
36 | name: "rabbitmq-server" | 42 | name: rabbitmq-server |
37 | state: started | 43 | state: started |
38 | enabled: yes | 44 | enabled: true |
39 | become: true | 45 | become: true |
40 | 46 | ||
41 | - name: fedora | enabling the RabbitMQ Management Console | 47 | - name: fedora | enabling the RabbitMQ Management Console |
diff --git a/tasks/main.yml b/tasks/main.yml index 8905c0b..1ef08f0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml | |||
@@ -1,3 +1,4 @@ | |||
1 | --- | ||
1 | # tasks file for ansible-rabbitmq | 2 | # tasks file for ansible-rabbitmq |
2 | - include: debian.yml | 3 | - include: debian.yml |
3 | when: ansible_os_family == "Debian" | 4 | when: ansible_os_family == "Debian" |
@@ -15,7 +16,8 @@ | |||
15 | when: rabbitmq_config_service | 16 | when: rabbitmq_config_service |
16 | 17 | ||
17 | - name: checking to see if already clustered | 18 | - name: checking to see if already clustered |
18 | stat: path=/etc/rabbitmq/clustered | 19 | stat: |
20 | path: /etc/rabbitmq/clustered | ||
19 | become: true | 21 | become: true |
20 | register: clustered | 22 | register: clustered |
21 | 23 | ||
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml index 9ebe297..cea301c 100644 --- a/tasks/rabbitmq_ha_config.yml +++ b/tasks/rabbitmq_ha_config.yml | |||
@@ -4,20 +4,13 @@ | |||
4 | path: /usr/sbin/rabbitmqadmin | 4 | path: /usr/sbin/rabbitmqadmin |
5 | register: rabbitmqadmin_check | 5 | register: rabbitmqadmin_check |
6 | 6 | ||
7 | - name: rabbitmq_ha_config | install rabbitMQ admin | 7 | - name: rabbit_ha_config | Installing rabbitMQ admin |
8 | shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin | 8 | get_url: |
9 | url: http://guest:guest@localhost:15672/cli/rabbitmqadmin | ||
10 | dest: /usr/sbin/rabbitmqadmin | ||
11 | mode: u=rwx,g=rw,o=rw | ||
9 | become: true | 12 | become: true |
10 | when: not rabbitmqadmin_check['stat']['exists'] | ||
11 | |||
12 | - name: rabbitmq_ha_config | moving the rabbitMQ Admin | ||
13 | shell: mv rabbitmqadmin /usr/sbin | ||
14 | become: true | ||
15 | when: not rabbitmqadmin_check['stat']['exists'] | ||
16 | |||
17 | - name: rabbitmq_ha_config | making executable rabbitMQ Admin | ||
18 | shell: chmod +x /usr/sbin/rabbitmqadmin | ||
19 | notify: restart rabbitmq-server | 13 | notify: restart rabbitmq-server |
20 | become: true | ||
21 | when: not rabbitmqadmin_check['stat']['exists'] | 14 | when: not rabbitmqadmin_check['stat']['exists'] |
22 | 15 | ||
23 | - name: rabbitmq_ha_config | creating queue(s) | 16 | - name: rabbitmq_ha_config | creating queue(s) |
diff --git a/tasks/redhat.yml b/tasks/redhat.yml index afa714c..0c7b97a 100644 --- a/tasks/redhat.yml +++ b/tasks/redhat.yml | |||
@@ -1,24 +1,27 @@ | |||
1 | --- | 1 | --- |
2 | - name: redhat | installing pre-reqs | 2 | - name: redhat | installing pre-reqs |
3 | yum: | 3 | yum: |
4 | name: "{{ item }}" | 4 | name: ['epel-release', 'wget'] |
5 | state: present | 5 | state: present |
6 | become: true | 6 | become: true |
7 | with_items: | 7 | register: result |
8 | - epel-release | 8 | until: result is successful |
9 | - wget | ||
10 | 9 | ||
11 | - name: redhat | installing erlang | 10 | - name: redhat | installing erlang |
12 | yum: | 11 | yum: |
13 | name: "erlang" | 12 | name: erlang |
14 | state: present | 13 | state: present |
15 | become: true | 14 | become: true |
15 | register: result | ||
16 | until: result is successful | ||
16 | 17 | ||
17 | - name: redhat | adding RabbitMQ public GPG key | 18 | - name: redhat | adding RabbitMQ public GPG key |
18 | rpm_key: | 19 | rpm_key: |
19 | key: "{{ rabbitmq_redhat_repo_key }}" | 20 | key: "{{ rabbitmq_redhat_repo_key }}" |
20 | state: present | 21 | state: present |
21 | become: true | 22 | become: true |
23 | register: result | ||
24 | until: result is successful | ||
22 | 25 | ||
23 | - name: redhat | downloading RabbitMQ | 26 | - name: redhat | downloading RabbitMQ |
24 | get_url: | 27 | get_url: |
@@ -31,10 +34,12 @@ | |||
31 | name: "/opt/{{ rabbitmq_redhat_package }}" | 34 | name: "/opt/{{ rabbitmq_redhat_package }}" |
32 | state: present | 35 | state: present |
33 | become: true | 36 | become: true |
37 | register: result | ||
38 | until: result is successful | ||
34 | 39 | ||
35 | - name: redhat | starting and enabling RabbitMQ service | 40 | - name: redhat | starting and enabling RabbitMQ service |
36 | service: | 41 | service: |
37 | name: "rabbitmq-server" | 42 | name: rabbitmq-server |
38 | state: started | 43 | state: started |
39 | enabled: yes | 44 | enabled: yes |
40 | become: true | 45 | become: true |