From fa0f0090b65c8432e737096a1058c8017f9c8518 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Mon, 14 May 2018 13:03:09 -0500 Subject: [PATCH] Add cleanup process when using embedded ansible When using the embedded ansible the deactivation process will now cleanup after itself. Change-Id: I5cf54d746e370c2886c49e0660f4e7b08ce05282 Signed-off-by: Kevin Carter --- elk_metrics_6x/bootstrap-embedded-ansible.sh | 18 +++++++++++++++ elk_metrics_6x/readme.rst | 24 ++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/elk_metrics_6x/bootstrap-embedded-ansible.sh b/elk_metrics_6x/bootstrap-embedded-ansible.sh index 5b814bc6..10b2f079 100644 --- a/elk_metrics_6x/bootstrap-embedded-ansible.sh +++ b/elk_metrics_6x/bootstrap-embedded-ansible.sh @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +export OPTS=() export ANSIBLE_EMBED_HOME="${HOME}/ansible25" +OPTS+=('ANSIBLE_EMBED_HOME') if [[ ! -e "${ANSIBLE_EMBED_HOME}/bin/ansible" ]]; then apt-get update @@ -51,21 +53,37 @@ EOF fi export USER_VARS="$(for i in $(ls -1 /etc/openstack_deploy/user_*secret*.yml); do echo -n "-e@$i "; done)" + OPTS+=('USER_VARS') echo "env USER_VARS set" echo "Extra users variables can be expanded by including the option \$USER_VARS on a playbook run." export ANSIBLE_INVENTORY="${ANSIBLE_EMBED_HOME}/inventory/openstack_inventory.sh" + OPTS+=('ANSIBLE_INVENTORY') echo "env ANSIBLE_INVENTORY set" fi export ANSIBLE_HOST_KEY_CHECKING="False" +OPTS+=('ANSIBLE_HOST_KEY_CHECKING') echo "env ANSIBLE_HOST_KEY_CHECKING set" export ANSIBLE_ROLES_PATH="${ANSIBLE_EMBED_HOME}/repositories/roles" +OPTS+=('ANSIBLE_ROLES_PATH') echo "env ANSIBLE_ACTION_PLUGINS set" export ANSIBLE_ACTION_PLUGINS="${ANSIBLE_EMBED_HOME}/repositories/ansible-config_template/action" +OPTS+=('ANSIBLE_ACTION_PLUGINS') echo "env ANSIBLE_ROLES_PATH set" source ${ANSIBLE_EMBED_HOME}/bin/activate echo "Embedded Ansible has been activated. Run 'deactivate' to leave the embedded environment". + +function deactivate_embedded_venv { + deactivate + for i in ${OPTS[@]}; do + unset ${i} + done + unset deactivate_embedded_venv + unalias deactivate +} + +alias deactivate=deactivate_embedded_venv diff --git a/elk_metrics_6x/readme.rst b/elk_metrics_6x/readme.rst index 29373384..1be2400a 100644 --- a/elk_metrics_6x/readme.rst +++ b/elk_metrics_6x/readme.rst @@ -106,7 +106,7 @@ Create the containers .. code-block:: bash cd /opt/openstack-ansible/playbooks - openstack-ansible lxc-containers-create.yml -e 'container_group=elastic-logstash:kibana' + openstack-ansible lxc-containers-create.yml -e 'container_group=elastic-logstash:kibana:apm-server' Deploying | Installing with embedded Ansible @@ -117,9 +117,9 @@ incompatible with these playbooks the script `bootstrap-embedded-ansible.sh` can be sourced to grab an embedded version of Ansible prior to executing the playbooks. -``` bash -source bootstrap-embedded-ansible.sh -``` +.. code-block:: bash + + source bootstrap-embedded-ansible.sh Deploying | Manually resolving the dependencies @@ -131,9 +131,10 @@ the `bootstrap-ansible.sh` script these dependencies can be resolved with the * Example galaxy execution -``` bash -ansible-galaxy install -r ansible-role-requirements.yml -``` +.. code-block:: bash + + ansible-galaxy install -r ansible-role-requirements.yml + Once the dependencies are set make sure to set the action plugin path to the location of the config_template action directory. This can be done using the @@ -176,6 +177,15 @@ Included dashboards. * https://grafana.com/dashboards/5569 * https://grafana.com/dashboards/5566 +Example command using the embedded Ansible from within the grafana directory. + +.. code-block:: bash + + ansible-playbook ${USER_VARS} installGrafana.yml \ + -e @../elk_metrics_6x/vars/variables.yml \ + -e galera_root_user=root \ + -e 'galera_address={{ internal_lb_vip_address }}' + Trouble shooting ----------------