Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Birin Sanchez
Shipwright - LDH Developer
Commits
f71fad70
Commit
f71fad70
authored
Dec 07, 2018
by
Noe Nieto
💬
Browse files
Add retry option for playbooks
parent
7aa5050b
Changes
1
Show whitespace changes
Inline
Side-by-side
shipyard/shipyard
View file @
f71fad70
...
...
@@ -134,18 +134,21 @@ def destroy_vm(hostname):
@
only_if_box_exist
def
run_playbook
(
hostname
,
playbook
):
def
run_playbook
(
hostname
,
playbook
,
retry_file
=
None
):
"""
run an Ansible playbook against this vm
"""
vagrant_wd
=
XDG_CONFIG_HOME
.
joinpath
(
hostname
)
inventory_file
=
vagrant_wd
.
joinpath
(
'.vagrant'
,
'provisioners'
,
'ansible'
,
'inventory'
,
'vagrant_ansible_inventory'
)
subprocess
.
run
(
[
_args
=
[
'ansible-playbook'
,
'-u'
,
'vagrant'
,
'-i'
,
f
'
{
inventory_file
}
'
,
f
'
{
Path
(
playbook
).
resolve
()
}
'
],
cwd
=
vagrant_wd
)
]
if
retry_file
:
_args
.
extend
([
'--limit'
,
f
'@
{
Path
(
retry_file
).
resolve
()
}
'
])
subprocess
.
run
(
_args
,
cwd
=
vagrant_wd
)
@
only_if_box_exist
...
...
@@ -234,8 +237,9 @@ if __name__ == '__main__':
if
cmd_args
.
command
==
'playbook'
:
sub_parser
.
usage
=
'shipyard playbook hostname path/to/playbook.yml'
sub_parser
.
add_argument
(
'playbook'
,
help
=
'The path to the playbook file'
)
sub_parser
.
add_argument
(
'--retry'
,
help
=
'The path to the playbook retry file.'
,
required
=
False
)
sub_args
=
sub_parser
.
parse_args
(
sys
.
argv
[
2
:])
run_playbook
(
sub_args
.
hostname
,
sub_args
.
playbook
)
run_playbook
(
sub_args
.
hostname
,
sub_args
.
playbook
,
sub_args
.
retry
)
sys
.
exit
()
sub_args
=
sub_parser
.
parse_args
(
sys
.
argv
[
2
:])
...
...
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