Add openstack collection

- add ansible-collection-requirements.yml so we
can specify the collections we need.
- Changed env-setup to install collections unsing
ansible-galaxy.

- Moved taks "Dynamic enrollment" to use the openstack.cloud
collection

Change-Id: I1cf21a505b923f333b6853944965593170cbe8cd
This commit is contained in:
Iury Gregory Melo Ferreira 2020-06-09 13:51:18 +02:00
parent 77a5ad3221
commit fa1b8ea9a0
5 changed files with 48 additions and 6 deletions

View File

@ -0,0 +1,4 @@
collections:
- name: openstack.cloud
version: 1.0.0
source: https://galaxy.ansible.com

View File

@ -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

View File

@ -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) }}"

View File

@ -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"

0
scripts/install-deps.sh Normal file → Executable file
View File