[tripleo][openstack-ansible][kolla-ansible] Packaging Ansible role and action_plugin for consuming outside OpenStack easily
Hello,
From last few months, we have started using openstack-ansible-os_tempest role developed under openstack-ansible project in TripleO for running tempest
os_tempest[1] role depends on ansible-role-python_venv_build[2] role and ansible-config_template[3] action plugin. In order to install these dependencies with os_tempest, we have changed the setup.cfg [data_files] section based on tripleo-quickstart setup.py file https://github.com/openstack/tripleo-quickstart/blob/master/setup.cfg#L27 [files] data_files = usr/local/share/tripleo-quickstart/roles = roles/* for python_venv_build and ansible-config_template, we tweaked role_path and action_plugin in ansible.cfg https://github.com/openstack/tripleo-quickstart/blob/master/ansible.cfg#L16 It is working fine. Later on, we started checking other roles and action plugins available on openstack ecosystem in order to make user experience easier, we found that ansible-role-tripleo-modify-image dumps it's files in share/ansible/roles/tripleo-modify-image/ directory [ https://github.com/openstack/ansible-role-tripleo-modify-image/blob/master/s...] and kolla-ansible is dumping all stuff at share/kolla-ansible/ansible [https://github.com/openstack/kolla-ansible/blob/master/setup.cfg#L27] and ceph-ansible can copied the config_template action_plugin to their own repo https://github.com/ceph/ceph-ansible/blob/master/plugins/actions/config_temp... so that end-user can just clone the role & action_plugin and just do python setup.py install In all above case, these are using python packaging format. Currently ansible looks for roles and plugins by default at following different places from https://github.com/ansible/ansible/blob/devel/lib/ansible/config/base.yml action_plugins: ~/.ansible/plugins/action:/usr/share/ansible/plugins/action roles_path: default: ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles By seeing that, we thought use to introduce requirements.yaml file to keep the ansible role requirements and then use ansible-galaxy install -r requirments.yaml it will install both the dependencies to ~/.ansible/roles directory but it will not load config_template action plugins and for enduser, we explicitly export the ANSIBLE_ACTION_PLUGINS to ~/.ansible/roles/config_template which is too much for an end user. Patch example: https://review.openstack.org/#/q/topic:ostempest_packaging+(status:open+OR+s...) For end user, we are looking for solution something like that or may be something better: git clone <os_tempest> then ansible-galaxy install or python setup.py install and we are done to run the playbook. But as you see above, different projects uses different ways of packaging the role and action plugins. Do we have defined standard around packaging ansible roles and ansible modules in OpenStack so that it will be easily consumable so that ansible can easily find the role and action_plugins? Like in terms of where to keep ansible role & action plugin while using setup.cfg or any other format. Thanks for reading, Links: [1.] https://github.com/openstack/openstack-ansible-os_tempest/ [2.] https://github.com/openstack/ansible-role-python_venv_build [3.] https://github.com/openstack/ansible-config_template Thanks, Chandan Kumar
Hi Chandan, You could load the config_template action plugin by cloning the role, as you are already doing, and then including the role in a playbook using the "roles:" tag, the import_role/include_role modules, or another role's meta dependency[0]. As long as you do one of these things prior to executing a task using the config_template module, it should be loaded into the plugins path for use. [0] https://github.com/logan2211/ansible-ramdisk-builder/blob/94940fea700d2f8f56... On Tue, Mar 19, 2019 at 6:53 AM Chandan kumar <chkumar246@gmail.com> wrote:
Hello,
From last few months, we have started using openstack-ansible-os_tempest role developed under openstack-ansible project in TripleO for running tempest
os_tempest[1] role depends on ansible-role-python_venv_build[2] role and ansible-config_template[3] action plugin.
In order to install these dependencies with os_tempest, we have changed the setup.cfg [data_files] section based on tripleo-quickstart setup.py file https://github.com/openstack/tripleo-quickstart/blob/master/setup.cfg#L27
[files] data_files = usr/local/share/tripleo-quickstart/roles = roles/*
for python_venv_build and ansible-config_template, we tweaked role_path and action_plugin in ansible.cfg https://github.com/openstack/tripleo-quickstart/blob/master/ansible.cfg#L16
It is working fine. Later on, we started checking other roles and action plugins available on openstack ecosystem in order to make user experience easier, we found that ansible-role-tripleo-modify-image dumps it's files in share/ansible/roles/tripleo-modify-image/ directory [ https://github.com/openstack/ansible-role-tripleo-modify-image/blob/master/s...] and kolla-ansible is dumping all stuff at share/kolla-ansible/ansible [https://github.com/openstack/kolla-ansible/blob/master/setup.cfg#L27]
and ceph-ansible can copied the config_template action_plugin to their own repo https://github.com/ceph/ceph-ansible/blob/master/plugins/actions/config_temp... so that end-user can just clone the role & action_plugin and just do python setup.py install
In all above case, these are using python packaging format.
Currently ansible looks for roles and plugins by default at following different places from https://github.com/ansible/ansible/blob/devel/lib/ansible/config/base.yml
action_plugins: ~/.ansible/plugins/action:/usr/share/ansible/plugins/action roles_path: default: ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
By seeing that, we thought use to introduce requirements.yaml file to keep the ansible role requirements and then use ansible-galaxy install -r requirments.yaml it will install both the dependencies to ~/.ansible/roles directory but it will not load config_template action plugins and for enduser, we explicitly export the ANSIBLE_ACTION_PLUGINS to ~/.ansible/roles/config_template which is too much for an end user.
Patch example: https://review.openstack.org/#/q/topic:ostempest_packaging+(status:open+OR+s...)
For end user, we are looking for solution something like that or may be something better: git clone <os_tempest> then ansible-galaxy install or python setup.py install and we are done to run the playbook.
But as you see above, different projects uses different ways of packaging the role and action plugins.
Do we have defined standard around packaging ansible roles and ansible modules in OpenStack so that it will be easily consumable so that ansible can easily find the role and action_plugins? Like in terms of where to keep ansible role & action plugin while using setup.cfg or any other format.
Thanks for reading,
Links: [1.] https://github.com/openstack/openstack-ansible-os_tempest/ [2.] https://github.com/openstack/ansible-role-python_venv_build [3.] https://github.com/openstack/ansible-config_template
Thanks,
Chandan Kumar
participants (2)
-
Chandan kumar
-
Logan V.