Simplify specification of playbooks in CLI
This commit is contained in:
parent
77c5f086f4
commit
a4b5c26c0f
@ -9,6 +9,11 @@ from kayobe import kolla_ansible
|
|||||||
from kayobe import utils
|
from kayobe import utils
|
||||||
|
|
||||||
|
|
||||||
|
def _build_playbook_list(*playbooks):
|
||||||
|
"""Return a list of names of playbook files given their basenames."""
|
||||||
|
return ["ansible/%s.yml" % playbook for playbook in playbooks]
|
||||||
|
|
||||||
|
|
||||||
class KayobeAnsibleMixin(object):
|
class KayobeAnsibleMixin(object):
|
||||||
"""Mixin class for commands running Kayobe Ansible playbooks."""
|
"""Mixin class for commands running Kayobe Ansible playbooks."""
|
||||||
|
|
||||||
@ -54,8 +59,7 @@ class ControlHostBootstrap(KayobeAnsibleMixin, Command):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
utils.yum_install(["ansible"])
|
utils.yum_install(["ansible"])
|
||||||
utils.galaxy_install("ansible/requirements.yml", "ansible/roles")
|
utils.galaxy_install("ansible/requirements.yml", "ansible/roles")
|
||||||
playbooks = ["ansible/%s.yml" % playbook for playbook in
|
playbooks = _build_playbook_list("bootstrap", "kolla")
|
||||||
"bootstrap", "kolla"]
|
|
||||||
ansible.run_playbooks(parsed_args, playbooks)
|
ansible.run_playbooks(parsed_args, playbooks)
|
||||||
|
|
||||||
|
|
||||||
@ -141,14 +145,13 @@ class SeedHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, Command):
|
|||||||
self.app.LOG.debug("Configuring seed host OS")
|
self.app.LOG.debug("Configuring seed host OS")
|
||||||
ansible_user = ansible.config_dump(parsed_args, host="seed",
|
ansible_user = ansible.config_dump(parsed_args, host="seed",
|
||||||
var_name="kayobe_ansible_user")
|
var_name="kayobe_ansible_user")
|
||||||
playbooks = ["ansible/%s.yml" % playbook for playbook in
|
playbooks = _build_playbook_list(
|
||||||
"ip-allocation", "ssh-known-host", "kayobe-ansible-user",
|
"ip-allocation", "ssh-known-host", "kayobe-ansible-user",
|
||||||
"disable-selinux", "network", "ntp", "lvm"]
|
"disable-selinux", "network", "ntp", "lvm")
|
||||||
ansible.run_playbooks(parsed_args, playbooks, limit="seed")
|
ansible.run_playbooks(parsed_args, playbooks, limit="seed")
|
||||||
kolla_ansible.run_seed(parsed_args, "bootstrap-servers",
|
kolla_ansible.run_seed(parsed_args, "bootstrap-servers",
|
||||||
extra_vars={"ansible_user": ansible_user})
|
extra_vars={"ansible_user": ansible_user})
|
||||||
playbooks = ["ansible/%s.yml" % playbook for playbook in
|
playbooks = _build_playbook_list("kolla-host", "docker")
|
||||||
"kolla-host", "docker"]
|
|
||||||
ansible.run_playbooks(parsed_args, playbooks, limit="seed")
|
ansible.run_playbooks(parsed_args, playbooks, limit="seed")
|
||||||
|
|
||||||
|
|
||||||
@ -218,14 +221,13 @@ class OvercloudHostConfigure(KollaAnsibleMixin, KayobeAnsibleMixin, Command):
|
|||||||
self.app.LOG.debug("Configuring overcloud host OS")
|
self.app.LOG.debug("Configuring overcloud host OS")
|
||||||
ansible_user = ansible.config_dump(parsed_args, host="controllers[0]",
|
ansible_user = ansible.config_dump(parsed_args, host="controllers[0]",
|
||||||
var_name="kayobe_ansible_user")
|
var_name="kayobe_ansible_user")
|
||||||
playbooks = ["ansible/%s.yml" % playbook for playbook in
|
playbooks = _build_playbook_list(
|
||||||
"ip-allocation", "ssh-known-host", "kayobe-ansible-user",
|
"ip-allocation", "ssh-known-host", "kayobe-ansible-user",
|
||||||
"disable-selinux", "network", "ntp", "lvm"]
|
"disable-selinux", "network", "ntp", "lvm")
|
||||||
ansible.run_playbooks(parsed_args, playbooks, limit="controllers")
|
ansible.run_playbooks(parsed_args, playbooks, limit="controllers")
|
||||||
kolla_ansible.run_overcloud(parsed_args, "bootstrap-servers",
|
kolla_ansible.run_overcloud(parsed_args, "bootstrap-servers",
|
||||||
extra_vars={"ansible_user": ansible_user})
|
extra_vars={"ansible_user": ansible_user})
|
||||||
playbooks = ["ansible/%s.yml" % playbook for playbook in
|
playbooks = _build_playbook_list("kolla-host", "docker")
|
||||||
"kolla-host", "docker"]
|
|
||||||
ansible.run_playbooks(parsed_args, playbooks, limit="controllers")
|
ansible.run_playbooks(parsed_args, playbooks, limit="controllers")
|
||||||
|
|
||||||
|
|
||||||
@ -234,8 +236,7 @@ class OvercloudServiceDeploy(KollaAnsibleMixin, KayobeAnsibleMixin, Command):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.app.LOG.debug("Deploying overcloud services")
|
self.app.LOG.debug("Deploying overcloud services")
|
||||||
playbooks = ["ansible/%s.yml" % playbook for playbook in
|
playbooks = _build_playbook_list("kolla-openstack", "swift-setup")
|
||||||
"kolla-openstack", "swift-setup"]
|
|
||||||
ansible.run_playbooks(parsed_args, playbooks)
|
ansible.run_playbooks(parsed_args, playbooks)
|
||||||
for command in ["pull", "prechecks", "deploy"]:
|
for command in ["pull", "prechecks", "deploy"]:
|
||||||
kolla_ansible.run_overcloud(parsed_args, command)
|
kolla_ansible.run_overcloud(parsed_args, command)
|
||||||
|
Loading…
Reference in New Issue
Block a user