forked from redhat-cop/automate-tower-ha-dr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtower-role-check.yml
More file actions
51 lines (43 loc) · 1.84 KB
/
tower-role-check.yml
File metadata and controls
51 lines (43 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- name: Ensure replication (potentially others in the future) are installed
hosts: localhost
vars:
external_role_path: roles_external
repl_role: samdoran.pgsql-replication
repl_role_archive_dir: ansible-role-pgsql-replication-master
tasks:
- name: see if {{repl_role}} role is installed
command: "ansible-galaxy -p {{ external_role_path }} list {{repl_role}}"
register: repl_role_status
- name: attempt {{repl_role}} install
block:
- name: ensure connectivity to galaxy
uri:
url: https://galaxy.ansible.com/api
register: galaxy_status
ignore_errors: yes
- name: if there is galaxy connectivity install from reqts file
block:
- name: ensure replication galaxy role is installed
command: "ansible-galaxy -p {{ external_role_path }} -r {{external_role_path}}/requirements.yml install"
when: not galaxy_status.failed
- name: no galaxy connectivity
block:
- name: check for extra vars
fail:
msg: |
No galaxy connectivity. Path to tar/zip containing {{repl_role}} role must be passed
as extra var 'replication_role_archive'
when: replication_role_archive is not defined
# NOTE: this is broken on MacOS 10.13. Ansible can't find gtar
# - name: extract role file to role directory
# unarchive:
# src: "{{replication_role_archive}}"
# dest: "{{ external_role_path}}"
# register: repl_role_extract
- name: extract role archive to role directory
command: "tar -C {{external_role_path}} -xzf {{replication_role_archive}}"
- name: normalize replication role path
command: "mv {{external_role_path}}/{{repl_role_archive_dir}} {{external_role_path}}/{{repl_role}}"
when: galaxy_status.failed
when: "'not found' in repl_role_status.stdout"