brpm_module_ansible 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/automations/execute_role.rb +2 -1
- data/config.yml +1 -1
- data/lib/ansible.rb +11 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODE2Yjc5MzNkN2Q5M2QxYjQ3OGJjYzJlMjE1YmQwODE5NzI4MjQ4NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjcxMDBjMDdlMjFlMDQ0NmFiYmI5Mjc5NjFhNmE4M2VhMGJkMjU0NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzhlMTgxMzM1NDYyMDQ2NDg0NzA2ZWE0N2RkYTJiOTY1YTVlZTlhODlkY2Jh
|
10
|
+
YTY2OWMzNmRjM2Y2MmExNDQyMmZjMmFmYTkzZDQ0YzU2MzFkYzAxNmVmZGJl
|
11
|
+
NDJmMzgzMThkMmUzZmMxMTI5ZTU2ZDZmODM2MWRmYmQzMDRmNGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDkyYjIxY2MwYTRiNjUwZGY2OWQ4MGFlYmY0NWY2ZDBlYjk2ZWM0NmEyOWM1
|
14
|
+
NzEyNjc3OWEyZThjYmMyODk3YTc2MTI0YmU1OTk3YzZhOTNlYzdhZjkxODFm
|
15
|
+
M2ZlZjkxNzRjMTI0ZmFhNTNjNzk5N2EyNWMxZWQwMzc4YzRlNjI=
|
data/automations/execute_role.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
brpm_rest_client = BrpmRestClient.new
|
2
2
|
server_group = brpm_rest_client.get_server_group_from_step_id(BrpmAuto.params.step_id)
|
3
3
|
|
4
|
-
|
4
|
+
ansible_client = AnsibleClient.new
|
5
|
+
ansible_client.execute_ansible_role(BrpmAuto.params["role"], server_group)
|
data/config.yml
CHANGED
data/lib/ansible.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
class AnsibleClient
|
2
|
+
def execute_ansible_role(role, server_group, ignore_error=false)
|
3
|
+
playbook_file_path = "/home/ansib/playbook_#{server_group}_#{role}_#{Time.now.strftime("%Y%m%d%H%M%S")}.yml"
|
4
|
+
playbook_content = <<EOF
|
4
5
|
---
|
5
6
|
# Make sure the facts of all servers are available for the role to be applied
|
6
7
|
- hosts: all
|
@@ -12,11 +13,13 @@ def execute_ansible_role(role, server_group, ignore_error=false)
|
|
12
13
|
- #{role}
|
13
14
|
EOF
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
BrpmAuto.log "Creating playbook.yml..."
|
17
|
+
File.open(playbook_file_path, 'w') {|f| f.write(playbook_content) }
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
_, _, stderr, status = BrpmAuto.execute_command "su ansib -c \"ansible-playbook #{playbook_file_path}\""
|
20
|
+
File.delete(playbook_file_path)
|
20
21
|
|
21
|
-
|
22
|
+
raise "The command failed with status #{status.exitstatus}.\n#{stderr}" unless status.success? or ignore_error
|
23
|
+
end
|
22
24
|
end
|
25
|
+
|