Support --kolla-playbook argument
Adds support for specifying a custom playbook when running Kolla Ansible commands via a '--kolla-playbook' argument. Change-Id: Ie4bba0f1bdc82657572e0f06a71db1140c0bd3a4
This commit is contained in:
parent
0c9912ece1
commit
79a8610030
@ -56,6 +56,8 @@ def add_args(parser):
|
|||||||
parser.add_argument("-kl", "--kolla-limit", metavar="SUBSET",
|
parser.add_argument("-kl", "--kolla-limit", metavar="SUBSET",
|
||||||
help="further limit selected hosts to an additional "
|
help="further limit selected hosts to an additional "
|
||||||
"pattern")
|
"pattern")
|
||||||
|
parser.add_argument("-kp", "--kolla-playbook", metavar="PLAYBOOK",
|
||||||
|
help="path to Ansible playbook file")
|
||||||
parser.add_argument("--kolla-skip-tags", metavar="TAGS",
|
parser.add_argument("--kolla-skip-tags", metavar="TAGS",
|
||||||
help="only run plays and tasks whose tags do not "
|
help="only run plays and tasks whose tags do not "
|
||||||
"match these values in Kolla Ansible")
|
"match these values in Kolla Ansible")
|
||||||
@ -104,6 +106,13 @@ def _validate_args(parsed_args, inventory_filename):
|
|||||||
parsed_args.kolla_venv, result["message"])
|
parsed_args.kolla_venv, result["message"])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if parsed_args.kolla_playbook:
|
||||||
|
result = utils.is_readable_file(parsed_args.kolla_playbook)
|
||||||
|
if not result["result"]:
|
||||||
|
LOG.error("Kolla Ansible playbook %s is invalid: %s",
|
||||||
|
parsed_args.kolla_playbook, result["message"])
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def build_args(parsed_args, command, inventory_filename, extra_vars=None,
|
def build_args(parsed_args, command, inventory_filename, extra_vars=None,
|
||||||
tags=None, verbose_level=None, extra_args=None, limit=None):
|
tags=None, verbose_level=None, extra_args=None, limit=None):
|
||||||
@ -113,6 +122,8 @@ def build_args(parsed_args, command, inventory_filename, extra_vars=None,
|
|||||||
cmd += ["kolla-ansible", command]
|
cmd += ["kolla-ansible", command]
|
||||||
if verbose_level:
|
if verbose_level:
|
||||||
cmd += ["-" + "v" * verbose_level]
|
cmd += ["-" + "v" * verbose_level]
|
||||||
|
if parsed_args.kolla_playbook:
|
||||||
|
cmd += ["--playbook", parsed_args.kolla_playbook]
|
||||||
cmd += vault.build_args(parsed_args, "--key")
|
cmd += vault.build_args(parsed_args, "--key")
|
||||||
inventory = _get_inventory_path(parsed_args, inventory_filename)
|
inventory = _get_inventory_path(parsed_args, inventory_filename)
|
||||||
cmd += ["--inventory", inventory]
|
cmd += ["--inventory", inventory]
|
||||||
|
@ -61,12 +61,14 @@ class TestCase(unittest.TestCase):
|
|||||||
"-ki", "/path/to/inventory",
|
"-ki", "/path/to/inventory",
|
||||||
"-kl", "host1:host2",
|
"-kl", "host1:host2",
|
||||||
"-kt", "tag1,tag2",
|
"-kt", "tag1,tag2",
|
||||||
|
"-kp", "/path/to/playbook",
|
||||||
]
|
]
|
||||||
parsed_args = parser.parse_args(args)
|
parsed_args = parser.parse_args(args)
|
||||||
kolla_ansible.run(parsed_args, "command", "overcloud")
|
kolla_ansible.run(parsed_args, "command", "overcloud")
|
||||||
expected_cmd = [
|
expected_cmd = [
|
||||||
".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&",
|
".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&",
|
||||||
"kolla-ansible", "command",
|
"kolla-ansible", "command",
|
||||||
|
"--playbook", "/path/to/playbook",
|
||||||
"--inventory", "/path/to/inventory",
|
"--inventory", "/path/to/inventory",
|
||||||
"--configdir", "/path/to/config",
|
"--configdir", "/path/to/config",
|
||||||
"--passwords", "/path/to/config/passwords.yml",
|
"--passwords", "/path/to/config/passwords.yml",
|
||||||
@ -98,6 +100,7 @@ class TestCase(unittest.TestCase):
|
|||||||
"--kolla-limit", "host1:host2",
|
"--kolla-limit", "host1:host2",
|
||||||
"--kolla-skip-tags", "tag3,tag4",
|
"--kolla-skip-tags", "tag3,tag4",
|
||||||
"--kolla-tags", "tag1,tag2",
|
"--kolla-tags", "tag1,tag2",
|
||||||
|
"--kolla-playbook", "/path/to/playbook",
|
||||||
]
|
]
|
||||||
parsed_args = parser.parse_args(args)
|
parsed_args = parser.parse_args(args)
|
||||||
mock_run.return_value = "/path/to/kayobe-vault-password-helper"
|
mock_run.return_value = "/path/to/kayobe-vault-password-helper"
|
||||||
@ -105,6 +108,7 @@ class TestCase(unittest.TestCase):
|
|||||||
expected_cmd = [
|
expected_cmd = [
|
||||||
".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&",
|
".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&",
|
||||||
"kolla-ansible", "command",
|
"kolla-ansible", "command",
|
||||||
|
"--playbook", "/path/to/playbook",
|
||||||
"--key", "/path/to/kayobe-vault-password-helper",
|
"--key", "/path/to/kayobe-vault-password-helper",
|
||||||
"--inventory", "/path/to/inventory",
|
"--inventory", "/path/to/inventory",
|
||||||
"--configdir", "/path/to/config",
|
"--configdir", "/path/to/config",
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Adds support for specifying a custom playbook when running Kolla Ansible
|
||||||
|
commands via a ``--kolla-playbook`` argument. For example:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
kayobe overcloud service deploy --kolla-playbook /path/to/playbook.yml
|
||||||
|
|
||||||
|
This may be used to specify a playbook that replaces or extends the default
|
||||||
|
``site.yml`` playbook, and needs to execute in the Kolla Ansible context.
|
Loading…
Reference in New Issue
Block a user