Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
9197f050
Commit
9197f050
authored
Aug 05, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed hyperleger inventory
parent
461fd918
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
ansible_service.py
deployer/service/ansible_service.py
+21
-17
No files found.
deployer/service/ansible_service.py
View file @
9197f050
...
@@ -65,17 +65,22 @@ class AnsibleService:
...
@@ -65,17 +65,22 @@ class AnsibleService:
arguments
=
'["-u","vm_user"]'
arguments
=
'["-u","vm_user"]'
if
playbook_name
==
'013.mount_fs.yml'
:
if
playbook_name
==
'013.mount_fs.yml'
:
master_ip
=
next
(
iter
(
master_ip
=
next
(
iter
(
inventory_dict
[
'all'
][
'children'
][
'swarm_manager_prime'
][
'hosts'
]))
# outputs 'foo'
inventory_dict
[
'all'
][
'children'
][
'swarm_manager_prime'
][
'hosts'
]))
arguments
=
'["-u","vm_user","--extra-vars","gluster_cluster_host0=
\'
'
+
master_ip
+
'
\'
gluster_cluster_volume=
\'
gfs0
\'
"]'
arguments
=
'["-u","vm_user","--extra-vars","gluster_cluster_host0=
\'
'
+
master_ip
+
'
\'
gluster_cluster_volume=
\'
gfs0
\'
"]'
task_id
=
self
.
run_task
(
name
,
project_id
,
key_id
,
git_url
,
inventory_id
,
playbook_name
,
task_id
=
self
.
run_task
(
name
,
project_id
,
key_id
,
git_url
,
inventory_id
,
playbook_name
,
environment_id
=
environment_id
,
arguments
=
arguments
)
environment_id
=
environment_id
,
arguments
=
arguments
)
if
self
.
semaphore_helper
.
get_task
(
project_id
,
task_id
)
.
status
!=
'success'
:
count
=
0
msg
=
' '
while
self
.
semaphore_helper
.
get_task
(
project_id
,
task_id
)
.
status
!=
'success'
:
for
out
in
self
.
semaphore_helper
.
get_task_outputs
(
project_id
,
task_id
):
task_id
=
self
.
run_task
(
name
,
project_id
,
key_id
,
git_url
,
inventory_id
,
playbook_name
,
msg
=
msg
+
' '
+
out
.
output
environment_id
=
environment_id
,
arguments
=
arguments
)
raise
Exception
(
count
+=
1
'Task: '
+
playbook_name
+
' failed. '
+
self
.
semaphore_helper
.
get_task
(
project_id
,
if
count
>=
3
:
task_id
)
.
status
+
' Output: '
+
msg
)
msg
=
' '
for
out
in
self
.
semaphore_helper
.
get_task_outputs
(
project_id
,
task_id
):
msg
=
msg
+
' '
+
out
.
output
raise
Exception
(
'Task: '
+
playbook_name
+
' failed. '
+
self
.
semaphore_helper
.
get_task
(
project_id
,
task_id
)
.
status
+
' Output: '
+
msg
)
tasks_outputs
[
task_id
]
=
self
.
semaphore_helper
.
get_task_outputs
(
project_id
,
task_id
)
tasks_outputs
[
task_id
]
=
self
.
semaphore_helper
.
get_task_outputs
(
project_id
,
task_id
)
...
@@ -202,26 +207,25 @@ class AnsibleService:
...
@@ -202,26 +207,25 @@ class AnsibleService:
elif
attributes
[
'role'
]
==
'worker'
:
elif
attributes
[
'role'
]
==
'worker'
:
roles
.
append
(
'swarm_workers'
)
roles
.
append
(
'swarm_workers'
)
public_ip
=
attributes
[
'public_ip'
]
public_ip
=
attributes
[
'public_ip'
]
# vars['ansible_host'] = public_ip
for
role
in
roles
:
for
role
in
roles
:
if
role
not
in
children
:
if
role
not
in
children
:
hosts
=
{}
hosts
=
{}
else
:
else
:
hosts
=
children
[
role
]
hosts
=
children
[
role
]
if
'hosts'
in
hosts
:
if
'hosts'
in
hosts
:
# if
attributes['role'] == 'master
':
# if
role == 'swarm_manager_prime' or role == 'swarm_managers
':
hosts
[
'hosts'
]
=
{
public_ip
:
vars
}
# hosts['hosts'] = {'fabric-manager'
: vars}
# else:
# else:
# hosts['hosts'] = {public_ip: vars}
# hosts['hosts'] = {'fabric-worker': vars}
hosts
[
'hosts'
]
=
{
public_ip
:
vars
}
else
:
else
:
host
=
{}
host
=
{}
host
[
public_ip
]
=
vars
host
[
public_ip
]
=
vars
# if role == 'swarm_manager_prime':
# if role == 'swarm_manager_prime' or role == 'swarm_managers':
# host['fabric-manager'] = vars
# host = {'fabric-manager': vars}
# elif role == 'swarm_managers':
# host['fabric-manager'] = {}
# else:
# else:
# host
['fabric-worker'] = vars
# host
= {'fabric-worker': vars}
hosts
[
'hosts'
]
=
host
hosts
[
'hosts'
]
=
host
children
[
role
]
=
hosts
children
[
role
]
=
hosts
all
[
'children'
]
=
children
all
[
'children'
]
=
children
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment