diff --git a/ansible-collection-requirements.yml b/ansible-collection-requirements.yml new file mode 100644 index 000000000..3f1421172 --- /dev/null +++ b/ansible-collection-requirements.yml @@ -0,0 +1,4 @@ +collections: + - name: openstack.cloud + version: 1.0.0 + source: https://galaxy.ansible.com diff --git a/doc/source/install/index.rst b/doc/source/install/index.rst index cbc3ee841..c7cdde1d7 100644 --- a/doc/source/install/index.rst +++ b/doc/source/install/index.rst @@ -198,12 +198,28 @@ Dependencies In order to really get started, you must install dependencies. -The ``env-setup.sh`` script automatically invokes ``install-deps.sh`` and -creates a virtual environment for you:: +With the addition of ansible collections, the ``env-setup.sh`` will install +the collections in the default ansible ``collections_paths`` (according to your +ansible.cfg) or you can specify the location setting +``ANSIBLE_COLLECTIONS_PATHS``: - bash ./scripts/env-setup.sh - source /opt/stack/bifrost/bin/activate - cd playbooks +.. code-block:: bash + + $ export ANSIBLE_COLLECTIONS_PATHS=/mydir/collections + +.. note:: + + If you are using a virtual environment ANSIBLE_COLLECTIONS_PATHS is + automatically set. + +The ``env-setup.sh`` script automatically invokes ``install-deps.sh`` and +creates a virtual environment for you: + +.. code-block:: bash + + $ bash ./scripts/env-setup.sh + $ source /opt/stack/bifrost/bin/activate + $ cd playbooks Once the dependencies are in-place, you can execute the ansible playbook to perform the actual installation. The playbook will install and configure diff --git a/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml b/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml index ab8f2b955..bf866d650 100644 --- a/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml +++ b/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml @@ -38,7 +38,7 @@ no_log: yes - name: "Dynamic enrollment" - os_ironic: + openstack.cloud.baremetal_node: cloud: "{{ cloud_name | default(omit) }}" auth_type: "{{ auth_type | default(omit) }}" auth: "{{ auth | default(omit) }}" diff --git a/scripts/env-setup.sh b/scripts/env-setup.sh index deaf215c8..5d765b645 100755 --- a/scripts/env-setup.sh +++ b/scripts/env-setup.sh @@ -9,13 +9,22 @@ DEFAULT_PIP_ANSIBLE='>=2.9,<2.10' ANSIBLE_PIP_VERSION=${ANSIBLE_PIP_VERSION:-${DEFAULT_PIP_ANSIBLE}} ANSIBLE_SOURCE_PATH=${ANSIBLE_SOURCE_PATH:-ansible${ANSIBLE_PIP_VERSION}} +ANSIBLE_COLLECTION_REQ=${ANSIBLE_COLLECTION_REQ:-$(dirname $0)/../ansible-collection-requirements.yml} +BIFROST_COLLECTIONS_PATHS=${ANSIBLE_COLLECTIONS_PATHS:-} if [ -n "${VENV-}" ]; then ${PIP} install "${ANSIBLE_SOURCE_PATH}" ANSIBLE=${VENV}/bin/ansible + ANSIBLE_GALAXY=${VENV}/bin/ansible-galaxy + if [[ -z $BIFROST_COLLECTIONS_PATHS ]]; then + echo "Setting ANSIBLE_COLLECTIONS_PATHS to virtualenv" + export ANSIBLE_COLLECTIONS_PATHS=${VENV}/collections + BIFROST_COLLECTIONS_PATHS=$ANSIBLE_COLLECTIONS_PATHS + fi else ${PIP} install --user --upgrade "${ANSIBLE_SOURCE_PATH}" ANSIBLE=${HOME}/.local/bin/ansible + ANSIBLE_GALAXY=${HOME}/.local/bin/ansible-galaxy fi PLAYBOOKS_LIBRARY_PATH=$(dirname $0)/../playbooks/library @@ -32,6 +41,19 @@ if [ ! -d ${ANSIBLE_INSTALL_ROOT} ]; then mkdir -p ${ANSIBLE_INSTALL_ROOT} || (sudo mkdir -p ${ANSIBLE_INSTALL_ROOT}) fi sudo -H chown -R $u:$g ${ANSIBLE_INSTALL_ROOT} + + +# Install Collections +if [[ -z $BIFROST_COLLECTIONS_PATHS ]]; +then + echo "Installing ansible collections on default collections path" + ${ANSIBLE_GALAXY} collection install -r ${ANSIBLE_COLLECTION_REQ} +else + echo "Installing ansible collections on $BIFROST_COLLECTIONS_PATHS" + ${ANSIBLE_GALAXY} collection install -r ${ANSIBLE_COLLECTION_REQ} -p ${BIFROST_COLLECTIONS_PATHS} +fi + + echo echo "To use bifrost, do" diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh old mode 100644 new mode 100755