[ English | Indonesia | Deutsch | English (United Kingdom) | русский | español ]
Extending OpenStack-Ansible with additional Ansible content¶
Termasuk OpenStack-Ansible dalam proyek Anda¶
Termasuk repositori openstack-ansible dalam proyek lain dapat dilakukan dengan beberapa cara:
Git submodule menunjuk ke tag yang dirilis.
Sebuah skrip untuk secara otomatis melakukan checkout git dari OpenStack-Ansible.
Ketika memasukkan OpenStack-Ansible dalam proyek, pertimbangkan untuk menggunakan struktur direktori paralel seperti yang ditunjukkan pada bagian file ansible.cfg
.
Juga perhatikan bahwa menyalin file ke direktori seperti env.d
atau conf.d
harus ditangani melalui semacam skrip dalam proyek ekstensi.
Termasuk OpenStack-Ansible dengan struktur Ansible Anda¶
Anda dapat membuat playbook, variabel, dan struktur peran Anda sendiri sambil tetap menyertakan peran dan pustaka yang dimungkinkan OpenStack dengan mengatur variabel lingkungan atau dengan menyesuaikan /usr/local/bin/openstack-ansible.rc
.
Variabel lingkungan yang relevan untuk OpenStack-Ansible adalah sebagai berikut:
ANSIBLE_LIBRARY
Variabel ini harus mengarah ke
/etc/ansible/plugins/library
. Melakukan hal itu memungkinkan peran dan playbook untuk mengakses modul Ansible yang disertakan OpenStack-Ansible.ANSIBLE_ROLES_PATH
Variabel ini harus menunjuk ke
/etc/ansible/roles
secara default. Hal ini memungkinkan Ansible untuk mencari peran OpenStack-Ansible yang dapat direferensikan oleh peran ekstensi.ANSIBLE_INVENTORY
Variabel ini harus mengarah ke
openstack-ansible/inventory/dynamic_inventory.py
. Dengan pengaturan ini, ekstensi memiliki akses ke inventaris dinamis yang sama yang menggunakan OpenStack-Ansible.
Path ke direktori level atas openstack-ansible
dapat bersifat relatif dalam file ini.
Pertimbangkan struktur direktori ini
my_project
|
|- custom_stuff
| |
| |- playbooks
|- openstack-ansible
| |
| |- playbooks
Variabel lingkungan yang ditetapkan akan digunakan ../openstack-ansible/playbooks/<directory>
.
Menambahkan peran baru atau utama dalam instalasi OpenStack-Ansible Anda¶
Secara default, OpenStack-Ansible menggunakan file ansible-role-requirement untuk mengambil peran yang diperlukan untuk proses instalasi.
Peran akan diambil ke standar ANSIBLE_ROLES_PATH
, yang standarnya adalah /etc/ansible/roles
.
ANSIBLE_ROLE_FILE
adalah variabel lingkungan yang menunjuk ke lokasi file YAML dimana ansible-galaxy dapat mengkonsumsi, menentukan dimana peran mengunduh dan menginstal. Nilai default untuk ini adalah ansible-role-requirements.yml
.
To completely override the ansible-role-requirement file you can define
the environment variable ANSIBLE_ROLE_FILE
before running the
bootstrap-ansible.sh
script. With this approach it is now the
responsibility of the deployer to maintain appropriate versions pins
of the ansible roles if an upgrade is required.
If you want to extend or just partially override content of the
ansible-role-requirements.yml
file you can create a new config file
which path defaults to /etc/openstack_deploy/user-role-requirements.yml
.
This path can be overriden with another environment variable
USER_ROLE_FILE
which is expected to be relative to OSA_CONFIG_DIR
(/etc/openstack_deploy) folder.
This file is in the same format as ansible-role-requirements.yml
and can be
used to add new roles or selectively override existing ones. New roles
listed in user-role-requirements.yml
will be merged with those
in ansible-role-requirements.yml
, and roles with matching name
key
will override those in ansible-role-requirements.yml
. In case when
src
key is not defined bootstrap script will skip cloning such roles.
It is easy for a deployer to keep this file under their own version control and out of the openstack-ansible tree.
Adding new or overriding collections in your OpenStack-Ansible installation¶
Alike to roles, collections for installation are stored in
ansible-collection-requirements file. Path to this file can be overriden
through ANSIBLE_COLLECTION_FILE
environmental variable.
The Victoria release of openstack-ansible adds an optional new config
file which defaults to
/etc/openstack_deploy/user-collection-requirements.yml
.
It should be in the native format of the ansible-galaxy requirements file
and can be used to add new collections to the deploy host or override versions
or source for collections defined in ansible-collection-requirements
.
user-collection-requirements
will be merged with
ansible-collection-requirements
using collection name
as a key.
In case source
is not defined in user-collection-requirements
,
collection installation will be skipped. This way you can skip installation
of unwanted collections.
You can override location of the user-collection-requirements.yml
by
setting USER_COLLECTION_FILE
environment variable before running the
bootstrap-ansible.sh
script. Though it is expected to be relative to
OSA_CONFIG_DIR
(/etc/openstack_deploy) folder.
Calling extra playbooks during the deployment¶
If you install some additional deployment functionality as either a collection or a git repository on the deploy host, it is possible to automatically include extra playbooks at certain points during the deployment.
The points where a hook exists to call an external playbook are as follows:
pre_setup_hosts_hook
post_setup_hosts_hook
pre_setup_infrastructure_hook
post_setup_infrastructure_hook
pre_setup_openstack_hook
post_setup_openstack_hook
The hook variables should be configured in a suitable user_variables file. An example calling a playbook from a collection (installed using user-collection-requirements.yml) :
pre_setup_hosts_hook: custom.collection.playbook
Installing extra playbooks using collections, and referencing the playbook with its FQCN is the most robust approach to including additional user defined playbooks.
Installing extra Python packages inside Ansible virtualenv¶
Some Ansible collections may require presence of specific Python libraries
inside execution environment.
In order to accomplish that deployer can create /etc/openstack_deploy/user-ansible-venv-requirements.txt
file with a list of Python libraries that should be installed inside virtual
environment along with Ansible during bootstrap-ansible.sh
execution.
You can override the default path to user-ansible-venv-requirements.txt
file
with USER_ANSIBLE_REQUIREMENTS_FILE
environment variable before running the
bootstrap-ansible.sh
script.
Defining environment variables for deployment¶
Throughout the documentation we talk a lot about different environment variables that control behaviour of OpenStack-Ansible and Ansible iteself.
Starting with the Zed release a user.rc
file can be placed in
OSA_CONFIG_DIR
(/etc/openstack_deploy) folder and contain any
environment variable definitions that might be needed to change the
default behaviour or any arbitrary Ansible configuration parameter.
These environment variables are general purpose and are not limited
to those understood by Ansible.
The path to this file can be changed by setting the OSA_USER_RC
variable, but the OSA_CONFIG_DIR
and OSA_USER_RC
variables
cannot re-defined or controlled through the user.rc
file.