diff --git a/ansible/group_vars/all/kolla b/ansible/group_vars/all/kolla index 0b89f629fd6c09d9e6055d9f0b22143fedb053d8..1087ed51c5d35284a75544f5dc39210025b8a232 100644 --- a/ansible/group_vars/all/kolla +++ b/ansible/group_vars/all/kolla @@ -5,6 +5,9 @@ # Type of Kolla control installation. One of 'binary' or 'source'. kolla_ctl_install_type: source +# Path to directory for kolla source code checkout. +kolla_source_path: "{{ source_checkout_path ~ '/kolla' }}" + # URL of Kolla source code repository if type is 'source'. kolla_source_url: "https://github.com/stackhpc/kolla" @@ -12,6 +15,18 @@ kolla_source_url: "https://github.com/stackhpc/kolla" # 'source'. kolla_source_version: "stackhpc-{{ kolla_openstack_release }}" +# Path to virtualenv in which to install kolla. +kolla_venv: "{{ virtualenv_path ~ '/kolla' }}" + +############################################################################### +# Kolla-ansible installation. + +# Type of Kolla-ansible control installation. One of 'binary' or 'source'. +kolla_ansible_ctl_install_type: source + +# Path to directory for kolla-ansible source code checkout. +kolla_ansible_source_path: "{{ lookup('env', 'KOLLA_SOURCE_PATH') | default(lookup('env', 'PWD') ~ '/src/kolla-ansible', true) }}" + # URL of Kolla Ansible source code repository if type is 'source'. kolla_ansible_source_url: "https://github.com/stackhpc/kolla-ansible" @@ -19,11 +34,11 @@ kolla_ansible_source_url: "https://github.com/stackhpc/kolla-ansible" # is 'source'. kolla_ansible_source_version: "stackhpc-{{ kolla_openstack_release }}" -# Path to virtualenv in which to install kolla. -kolla_venv: "{{ virtualenv_path ~ '/kolla' }}" +# Path to virtualenv in which to install kolla-ansible. +kolla_ansible_venv: "{{ lookup('env', 'KOLLA_VENV_PATH') | default(lookup('env', 'PWD') ~ '/venvs/kolla-ansible', true) }}" ############################################################################### -# Kolla configuration. +# Kolla & kolla-ansible configuration. # Path to Kolla configuration directory. kolla_config_path: "{{ lookup('env', 'KOLLA_CONFIG_PATH') | default('/etc/kolla', true) }}" diff --git a/ansible/roles/kolla-ansible/defaults/main.yml b/ansible/roles/kolla-ansible/defaults/main.yml index 0321ab6cf11ac40fdbf420b631e18ebd8c0c598c..9be0d1ad427adaf7345ff034061c612f577466a3 100644 --- a/ansible/roles/kolla-ansible/defaults/main.yml +++ b/ansible/roles/kolla-ansible/defaults/main.yml @@ -1,9 +1,9 @@ --- -# Path to directory for source code checkouts. -source_checkout_path: +# Path to directory for kolla-ansible source code checkout. +kolla_ansible_source_path: -# Type of Kolla control installation. One of 'binary' or 'source'. -kolla_ctl_install_type: +# Type of Kolla-ansible control installation. One of 'binary' or 'source'. +kolla_ansible_ctl_install_type: # URL of Kolla Ansible source code repository if type is 'source'. kolla_ansible_source_url: @@ -13,7 +13,7 @@ kolla_ansible_source_url: kolla_ansible_source_version: # Virtualenv directory where Kolla-ansible will be installed. -kolla_venv: "{{ ansible_env['PWD'] }}/kolla-venv" +kolla_ansible_venv: "{{ ansible_env['PWD'] }}/kolla-venv" # Password to use to encrypt the passwords.yml file. kolla_ansible_vault_password: diff --git a/ansible/roles/kolla-ansible/tasks/config.yml b/ansible/roles/kolla-ansible/tasks/config.yml index b7d80703d76e425c3826a584e11f1b7f9bfd6e21..1a2686c983e93a47ec8ff06307cd2b520e8d88e4 100644 --- a/ansible/roles/kolla-ansible/tasks/config.yml +++ b/ansible/roles/kolla-ansible/tasks/config.yml @@ -41,7 +41,7 @@ sample: "{{ kolla_ansible_install_dir }}/etc_examples/kolla/passwords.yml" overrides: "{{ kolla_ansible_custom_passwords }}" vault_password: "{{ kolla_ansible_vault_password }}" - virtualenv: "{{ kolla_venv or omit }}" + virtualenv: "{{ kolla_ansible_venv or omit }}" - name: Ensure the Kolla passwords file is copied into place copy: diff --git a/ansible/roles/kolla-ansible/tasks/install.yml b/ansible/roles/kolla-ansible/tasks/install.yml index dd0ee5aca6bc18a091b1e54db17c854cc2019d4a..172eb2d7119442d0ca34d669fc4f71baec20ab01 100644 --- a/ansible/roles/kolla-ansible/tasks/install.yml +++ b/ansible/roles/kolla-ansible/tasks/install.yml @@ -16,27 +16,27 @@ become: True with_items: "{{ kolla_ansible_package_dependencies }}" -- name: Ensure source code checkout path exists +- name: Ensure source code checkout parent directory exists file: - path: "{{ source_checkout_path }}" + path: "{{ kolla_ansible_source_path | dirname }}" state: directory owner: "{{ ansible_user }}" group: "{{ ansible_user }}" become: True - when: "{{ kolla_ctl_install_type == 'source' }}" + when: "{{ kolla_ansible_ctl_install_type == 'source' }}" - name: Ensure Kolla Ansible source code checkout exists git: repo: "{{ kolla_ansible_source_url }}" - dest: "{{ source_checkout_path }}/kolla-ansible" + dest: "{{ kolla_ansible_source_path }}" version: "{{ kolla_ansible_source_version }}" - when: "{{ kolla_ctl_install_type == 'source' }}" + when: "{{ kolla_ansible_ctl_install_type == 'source' }}" - name: Ensure the latest version of pip is installed pip: name: "{{ item.name }}" state: latest - virtualenv: "{{ kolla_venv }}" + virtualenv: "{{ kolla_ansible_venv }}" with_items: - { name: pip } @@ -45,15 +45,15 @@ name: "{{ item.name }}" version: "{{ item.version | default(omit) }}" state: present - virtualenv: "{{ kolla_venv }}" + virtualenv: "{{ kolla_ansible_venv }}" with_items: # Intall Kolla Ansible from source. - - name: "{{ source_checkout_path }}/kolla-ansible" - install: "{{ kolla_ctl_install_type == 'source' }}" + - name: "{{ kolla_ansible_source_path }}" + install: "{{ kolla_ansible_ctl_install_type == 'source' }}" # Intall Kolla Ansible from PyPI. - name: "kolla-ansible" version: "{{ kolla_openstack_release }}" - install: "{{ kolla_ctl_install_type == 'binary' }}" + install: "{{ kolla_ansible_ctl_install_type == 'binary' }}" # On CentOS 7.3 Jinja2==2.7, but kolla-ansible requires 2.8. Install # Ansible to ensure we pull in and use a later Jinja2. - name: "ansible" @@ -70,7 +70,7 @@ - name: Ensure selinux Python package is linked into the virtualenv file: src: "/usr/lib64/python2.7/site-packages/selinux" - dest: "{{ kolla_venv }}/lib/python2.7/site-packages/selinux" + dest: "{{ kolla_ansible_venv }}/lib/python2.7/site-packages/selinux" state: link when: - ansible_selinux != False diff --git a/ansible/roles/kolla-ansible/vars/main.yml b/ansible/roles/kolla-ansible/vars/main.yml index d6717225d467078764687218fa5636d1ed84dbc2..143ede9f4431bc81e1166ac5b1fa40eb15fdb48d 100644 --- a/ansible/roles/kolla-ansible/vars/main.yml +++ b/ansible/roles/kolla-ansible/vars/main.yml @@ -6,7 +6,7 @@ kolla_ansible_is_standalone: "{{ kolla_ansible_source_version | version_compare( kolla_ansible_module: "{% if kolla_ansible_is_standalone | bool %}kolla-ansible{% else %}kolla{% endif %}" # Path to Kolla Ansible installation directory. -kolla_ansible_install_dir: "{{ kolla_venv }}/share/{{ kolla_ansible_module }}" +kolla_ansible_install_dir: "{{ kolla_ansible_venv }}/share/{{ kolla_ansible_module }}" ############################################################################### # Inventory configuration. diff --git a/ansible/roles/kolla/defaults/main.yml b/ansible/roles/kolla/defaults/main.yml index 34be6497119b808340992ad748b16b08a7809a21..315bb30af5333d753ae8767df3c848a08d802d88 100644 --- a/ansible/roles/kolla/defaults/main.yml +++ b/ansible/roles/kolla/defaults/main.yml @@ -1,6 +1,6 @@ --- -# Path to directory for source code checkouts. -source_checkout_path: +# Path to directory for kolla source code checkout. +kolla_source_path: # Type of Kolla control installation. One of 'binary' or 'source'. kolla_ctl_install_type: diff --git a/ansible/roles/kolla/tasks/install.yml b/ansible/roles/kolla/tasks/install.yml index 291059cf8de37dbacbb14c4f9555d80142e40507..30314806ac5d517d35ad6168c2b64f3d55557999 100644 --- a/ansible/roles/kolla/tasks/install.yml +++ b/ansible/roles/kolla/tasks/install.yml @@ -20,7 +20,7 @@ - name: Ensure source code checkout path exists file: - path: "{{ source_checkout_path }}" + path: "{{ kolla_source_path | dirname }}" state: directory owner: "{{ ansible_user }}" group: "{{ ansible_user }}" @@ -30,7 +30,7 @@ - name: Ensure Kolla source code checkout exists git: repo: "{{ kolla_source_url }}" - dest: "{{ source_checkout_path }}/kolla" + dest: "{{ kolla_source_path }}" version: "{{ kolla_source_version }}" when: "{{ kolla_ctl_install_type == 'source' }}" @@ -50,7 +50,7 @@ virtualenv: "{{ kolla_venv }}" with_items: # Intall Kolla from source. - - name: "{{ source_checkout_path }}/kolla" + - name: "{{ kolla_source_path }}" install: "{{ kolla_ctl_install_type == 'source' }}" # Intall Kolla from PyPI. - name: "kolla" diff --git a/doc/source/configuration/kolla-ansible.rst b/doc/source/configuration/kolla-ansible.rst new file mode 100644 index 0000000000000000000000000000000000000000..2f3cf0c320648cc401f89f29970494bbc95a79db --- /dev/null +++ b/doc/source/configuration/kolla-ansible.rst @@ -0,0 +1,27 @@ +=========================== +Kolla-ansible Configuration +=========================== + +Kayobe relies heavily on kolla-ansible for deployment of the OpenStack control +plane. Kolla-ansible is installed locally on the ansible control host (the host +from which kayobe commands are executed), and kolla-ansible commands are +executed from there. + +Local Environment +================= + +Environment variables are used to configure the environment in which +kolla-ansible is installed and executed. + +.. table:: Kolla-ansible environment variables + + ====================== ================================================== ============================ + Variable Purpose Default + ====================== ================================================== ============================ + ``$KOLLA_CONFIG_PATH`` Path on the ansible control host in which ``/etc/kolla`` + the kolla-ansible configuration will be generated. + ``$KOLLA_SOURCE_PATH`` Path on the ansible control host in which ``$PWD/src/kolla-ansible`` + the kolla-ansible source code will be cloned. + ``$KOLLA_VENV_PATH`` Path on the ansible control host in which ``$PWD/venvs/kolla-ansible`` + the kolla-ansible virtualenv will be created. + ====================== ================================================== ============================ diff --git a/doc/source/index.rst b/doc/source/index.rst index a34cd9b268b98d401c290176ab890dfd4bf20797..210101b141d8ccb6a1cdf89b57bbdc2a4e784151 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -25,6 +25,7 @@ Documentation usage configuration/kayobe configuration/network + configuration/kolla-ansible deployment upgrading administration diff --git a/etc/kayobe/kolla.yml b/etc/kayobe/kolla.yml index 21be075003098cdf5080f4f6b633764557035644..78a4d7e775457fabe4100b6296c22b821fc858f1 100644 --- a/etc/kayobe/kolla.yml +++ b/etc/kayobe/kolla.yml @@ -7,6 +7,9 @@ # Type of Kolla control installation. One of 'binary' or 'source'. #kolla_ctl_install_type: +# Path to directory for kolla source code checkout. +#kolla_source_path: + # URL of Kolla source code repository if type is 'source'. #kolla_source_url: @@ -14,6 +17,18 @@ # 'source'. #kolla_source_version: +# Path to virtualenv in which to install kolla. +#kolla_venv: + +############################################################################### +# Kolla-ansible installation. + +# Type of Kolla-ansible control installation. One of 'binary' or 'source'. +#kolla_ansible_ctl_install_type: + +# Path to directory for kolla-ansible source code checkout. +#kolla_ansible_source_path: + # URL of Kolla Ansible source code repository if type is 'source'. #kolla_ansible_source_url: @@ -21,12 +36,18 @@ # is 'source'. #kolla_ansible_source_version: +# Path to virtualenv in which to install kolla-ansible. +#kolla_ansible_venv: + ############################################################################### -# Kolla configuration. +# Kolla & kolla-ansible configuration. # Path to Kolla configuration directory. #kolla_config_path: +# Path to Kolla node custom configuration directory. +#kolla_node_custom_config_path: + # Kolla base container image distribution. #kolla_base_distro: diff --git a/kayobe/kolla_ansible.py b/kayobe/kolla_ansible.py index 3819735aed9303324a2c08dc400535e3ecdaff6e..49ca3269a11bd9c04358b25dfd6fdfea34cb3d4d 100644 --- a/kayobe/kolla_ansible.py +++ b/kayobe/kolla_ansible.py @@ -25,24 +25,20 @@ DEFAULT_CONFIG_PATH = "/etc/kolla" CONFIG_PATH_ENV = "KOLLA_CONFIG_PATH" -DEFAULT_BASE_PATH = "/opt/kayobe" +DEFAULT_VENV_PATH = "venvs/kolla-ansible" -BASE_PATH_ENV = "KAYOBE_BASE_PATH" - -DEFAULT_VENV_PATH = "venvs/kolla" - -VENV_PATH_ENV = "KOLLA_VENV" +VENV_PATH_ENV = "KOLLA_VENV_PATH" LOG = logging.getLogger(__name__) def add_args(parser): """Add arguments required for running Kolla Ansible to a parser.""" + # $KOLLA_CONFIG_PATH or /etc/kolla. default_config_path = os.getenv(CONFIG_PATH_ENV, DEFAULT_CONFIG_PATH) + # $KOLLA_VENV_PATH or $PWD/venvs/kolla-ansible default_venv = os.getenv(VENV_PATH_ENV, - os.path.join(os.getenv(BASE_PATH_ENV, - DEFAULT_BASE_PATH), - DEFAULT_VENV_PATH)) + os.path.join(os.getcwd(), DEFAULT_VENV_PATH)) parser.add_argument("--kolla-config-path", default=default_config_path, help="path to Kolla configuration. " "(default=$%s or %s)" % @@ -64,9 +60,8 @@ def add_args(parser): "values in Kolla Ansible") parser.add_argument("--kolla-venv", metavar="VENV", default=default_venv, help="path to virtualenv where Kolla Ansible is " - "installed (default=$%s or $%s/%s, or %s/%s)" % - (VENV_PATH_ENV, BASE_PATH_ENV, DEFAULT_VENV_PATH, - DEFAULT_BASE_PATH, DEFAULT_VENV_PATH)) + "installed (default=$%s or $PWD/%s)" % + (VENV_PATH_ENV, DEFAULT_VENV_PATH)) def _get_inventory_path(parsed_args, inventory_filename): diff --git a/kayobe/tests/unit/test_kolla_ansible.py b/kayobe/tests/unit/test_kolla_ansible.py index 78de660be84a4bb32b743b65e750868975cf6f24..d12b46709cd2fcb7d30fcc13b2c1702bef51d04d 100644 --- a/kayobe/tests/unit/test_kolla_ansible.py +++ b/kayobe/tests/unit/test_kolla_ansible.py @@ -24,6 +24,7 @@ from kayobe import utils from kayobe import vault +@mock.patch.object(os, "getcwd", new=lambda: "/path/to/cwd") class TestCase(unittest.TestCase): @mock.patch.object(utils, "run_command") @@ -35,7 +36,7 @@ class TestCase(unittest.TestCase): parsed_args = parser.parse_args([]) kolla_ansible.run(parsed_args, "command", "overcloud") expected_cmd = [ - ".", "/opt/kayobe/venvs/kolla/bin/activate", "&&", + ".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&", "kolla-ansible", "command", "--inventory", "/etc/kolla/inventory/overcloud", ] @@ -58,7 +59,7 @@ class TestCase(unittest.TestCase): parsed_args = parser.parse_args(args) kolla_ansible.run(parsed_args, "command", "overcloud") expected_cmd = [ - ".", "/opt/kayobe/venvs/kolla/bin/activate", "&&", + ".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&", "kolla-ansible", "command", "--inventory", "/path/to/inventory", "--configdir", "/path/to/config", @@ -87,7 +88,7 @@ class TestCase(unittest.TestCase): parsed_args = parser.parse_args(args) kolla_ansible.run(parsed_args, "command", "overcloud") expected_cmd = [ - ".", "/opt/kayobe/venvs/kolla/bin/activate", "&&", + ".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&", "kolla-ansible", "command", "--inventory", "/path/to/inventory", "--configdir", "/path/to/config", @@ -111,7 +112,7 @@ class TestCase(unittest.TestCase): parsed_args = parser.parse_args(args) kolla_ansible.run(parsed_args, "command", "overcloud") expected_cmd = [ - ".", "/opt/kayobe/venvs/kolla/bin/activate", "&&", + ".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&", "kolla-ansible", "command", "--key", "/path/to/vault/pw", "--inventory", "/etc/kolla/inventory/overcloud", @@ -134,7 +135,7 @@ class TestCase(unittest.TestCase): parsed_args = parser.parse_args([]) kolla_ansible.run(parsed_args, "command", "overcloud") expected_cmd = [ - ".", "/opt/kayobe/venvs/kolla/bin/activate", "&&", + ".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&", "kolla-ansible", "command", "--key", "/path/to/kayobe-vault-password-helper", "--inventory", "/etc/kolla/inventory/overcloud", @@ -161,7 +162,7 @@ class TestCase(unittest.TestCase): } kolla_ansible.run(parsed_args, "command", "overcloud", **kwargs) expected_cmd = [ - ".", "/opt/kayobe/venvs/kolla/bin/activate", "&&", + ".", "/path/to/cwd/venvs/kolla-ansible/bin/activate", "&&", "kolla-ansible", "command", "-v", "--inventory", "/etc/kolla/inventory/overcloud",