Fix ansible path for elk_metrics_6x tests

Fix the failing elk_metrics_6x tests by changing the ansible venv path
to ~/ansible_venv.  Update tests to ensure when the bootstrap ansible
script changes both osquery and elk_metrics_6x tests are run.

Change-Id: Ic79c52ae21294373ca67be264fd287fdf32b4c9a
This commit is contained in:
Michael Vollman 2018-11-01 10:33:20 -04:00 committed by Kevin Carter
parent 58c7890bfc
commit b5ed2d024f
10 changed files with 62 additions and 60 deletions

View File

@ -19,7 +19,7 @@ Usage
source bootstrap-embedded-ansible.sh source bootstrap-embedded-ansible.sh
With the script sourced, the ansible enviornment will create a virtual environment at With the script sourced, the ansible environment will create a virtual environment at
`${HOME}/ansible${ANSIBLE_VERSION}` if it does not already exist. `${HOME}/ansible_venv` if it does not already exist.
To leave the embedded ansible enviornment run the function `deactivate`. To leave the embedded ansible enviornment run the function `deactivate`.

View File

@ -15,7 +15,7 @@
export OPTS=() export OPTS=()
export ANSIBLE_VERSION="${ANSIBLE_VERSION:-2.5.5.0}" export ANSIBLE_VERSION="${ANSIBLE_VERSION:-2.5.5.0}"
export ANSIBLE_EMBED_HOME="${HOME}/ansible${ANSIBLE_VERSION}" export ANSIBLE_EMBED_HOME="${HOME}/ansible_venv"
OPTS+=('ANSIBLE_EMBED_HOME') OPTS+=('ANSIBLE_EMBED_HOME')
source /etc/os-release source /etc/os-release

View File

@ -60,7 +60,7 @@
reload: "yes" reload: "yes"
sysctl_file: /etc/sysctl.d/99-elasticsearch.conf sysctl_file: /etc/sysctl.d/99-elasticsearch.conf
- name: Create tmp osquery dir - name: Create tmp elk_metrics_6x dir
file: file:
path: "/tmp/elk-metrics-6x-logs" path: "/tmp/elk-metrics-6x-logs"
state: directory state: directory
@ -98,26 +98,26 @@
- name: Run ansible-galaxy (tests) - name: Run ansible-galaxy (tests)
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-galaxy install --force --ignore-errors --roles-path=/root/ansible25/repositories/roles -r ansible-role-requirements.yml" command: "${HOME}/ansible_venv/bin/ansible-galaxy install --force --ignore-errors --roles-path=${HOME}/ansible_venv/repositories/roles -r ansible-role-requirements.yml"
args: args:
chdir: "src/{{ current_test_repo }}/osquery/tests" chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests"
- name: Run ansible-galaxy (elk_metrics_6x) - name: Run ansible-galaxy (elk_metrics_6x)
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-galaxy install --force --ignore-errors --roles-path=/root/ansible25/repositories/roles -r ansible-role-requirements.yml" command: "${HOME}/ansible_venv/bin/ansible-galaxy install --force --ignore-errors --roles-path=${HOME}/ansible_venv/repositories/roles -r ansible-role-requirements.yml"
args: args:
chdir: "src/{{ current_test_repo }}/osquery" chdir: "src/{{ current_test_repo }}/elk_metrics_6x"
- name: Run environment setup - name: Run environment setup
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _key-setup.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _key-setup.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-container-setup.log" ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-container-setup.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests" chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests"
when: when:
@ -127,12 +127,12 @@
- name: Run environment setup - name: Run environment setup
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _container-setup.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _container-setup.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-container-setup.log" ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-container-setup.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests" chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests"
when: when:
@ -148,23 +148,23 @@
- name: Run functional test - name: Run functional test
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i tests/{{ inventory_file }} -e @tests/test-vars.yml site.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i tests/{{ inventory_file }} -e @tests/test-vars.yml site.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-deployment.log" ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-deployment.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/elk_metrics_6x" chdir: "src/{{ current_test_repo }}/elk_metrics_6x"
- name: Show cluster state - name: Show cluster state
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i tests/{{ inventory_file }} -e @tests/test-vars.yml showElasticCluster.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i tests/{{ inventory_file }} -e @tests/test-vars.yml showElasticCluster.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-show-cluster.log" ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-show-cluster.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/elk_metrics_6x" chdir: "src/{{ current_test_repo }}/elk_metrics_6x"

View File

@ -1,7 +1,7 @@
export ANSIBLE_HOST_KEY_CHECKING="False" export ANSIBLE_HOST_KEY_CHECKING="False"
export ANSIBLE_ROLES_PATH="${HOME}/ansible25/repositories/roles" export ANSIBLE_ROLES_PATH="${HOME}/ansible_venv/repositories/roles"
export ANSIBLE_ACTION_PLUGINS="${HOME}/ansible25/repositories/roles/config_template/action" export ANSIBLE_ACTION_PLUGINS="${HOME}/ansible_venv/repositories/roles/config_template/action"
export ANSIBLE_CONNECTION_PLUGINS="${HOME}/ansible25/repositories/roles/plugins/connection" export ANSIBLE_CONNECTION_PLUGINS="${HOME}/ansible_venv/repositories/roles/plugins/connection"
export ANSIBLE_LOG_PATH="/tmp/elk-metrics-6x-logs/ansible-elk-test.log" export ANSIBLE_LOG_PATH="/tmp/elk-metrics-6x-logs/ansible-elk-test.log"
if [[ ! -d "/tmp/elk-metrics-6x-logs" ]]; then if [[ ! -d "/tmp/elk-metrics-6x-logs" ]]; then
@ -10,7 +10,7 @@ if [[ ! -d "/tmp/elk-metrics-6x-logs" ]]; then
fi fi
echo "To build a test environment run the following:" echo "To build a test environment run the following:"
echo -e "# /root/ansible25/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml tests/test.yml --limit localhost\n" echo -e "# ${HOME}/ansible_venv/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml tests/test.yml --limit localhost\n"
echo "Run manual functional tests by executing the following:" echo "Run manual functional tests by executing the following:"
echo -e "# /root/ansible25/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml site.yml\n" echo -e "# ${HOME}/ansible_venv/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml site.yml\n"

View File

@ -26,20 +26,20 @@ pushd "${HOME}"
popd popd
popd popd
source "${TEST_DIR}/osquery/tests/manual-test.rc" source "${TEST_DIR}/elk_metrics_6x/tests/manual-test.rc"
source "${TEST_DIR}/osquery/bootstrap-embedded-ansible.sh" source "${TEST_DIR}/elk_metrics_6x/bootstrap-embedded-ansible.sh"
deactivate deactivate
${HOME}/ansible25/bin/ansible-galaxy install --force \ ${HOME}/ansible_venv/bin/ansible-galaxy install --force \
--roles-path="${HOME}/ansible25/repositories/roles" \ --roles-path="${HOME}/ansible_venv/repositories/roles" \
--role-file="${TEST_DIR}/elk_metrics_6x/tests/ansible-role-requirements.yml" --role-file="${TEST_DIR}/elk_metrics_6x/tests/ansible-role-requirements.yml"
if [[ ! -e "${TEST_DIR}/osquery/tests/src" ]]; then if [[ ! -e "${TEST_DIR}/elk_metrics_6x/tests/src" ]]; then
ln -s ${TEST_DIR}/../ ${TEST_DIR}/osquery/tests/src ln -s ${TEST_DIR}/../ ${TEST_DIR}/elk_metrics_6x/tests/src
fi fi
${HOME}/ansible25/bin/ansible-playbook -i 'localhost,' \ ${HOME}/ansible_venv/bin/ansible-playbook -i 'localhost,' \
-vv \ -vv \
-e ansible_connection=local \ -e ansible_connection=local \
-e test_clustered_elk=${CLUSTERED:-no} \ -e test_clustered_elk=${CLUSTERED:-no} \

View File

@ -129,14 +129,14 @@ the `bootstrap-ansible.sh` script these dependencies can be resolved with the
.. code-block:: bash .. code-block:: bash
ansible-galaxy install -r ansible-role-requirements.yml --roles-path=~/ansible25/repositories/roles ansible-galaxy install -r ansible-role-requirements.yml --roles-path=~/ansible_venv/repositories/roles
In the even that some of the modules are alread installed execute the following In the even that some of the modules are alread installed execute the following
.. code-block:: bash .. code-block:: bash
ansible-galaxy install -r ansible-role-requirements.yml --ignore-errors --roles-path=~/ansible25/repositories/roles ansible-galaxy install -r ansible-role-requirements.yml --ignore-errors --roles-path=~/ansible_venv/repositories/roles
Once the dependencies are set make sure to set the action plugin path to the Once the dependencies are set make sure to set the action plugin path to the

View File

@ -98,26 +98,26 @@
- name: Run ansible-galaxy (tests) - name: Run ansible-galaxy (tests)
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-galaxy install --force --ignore-errors --roles-path=/root/ansible25/repositories/roles -r ansible-role-requirements.yml" command: "${HOME}/ansible_venv/bin/ansible-galaxy install --force --ignore-errors --roles-path=${HOME}/ansible_venv/repositories/roles -r ansible-role-requirements.yml"
args: args:
chdir: "src/{{ current_test_repo }}/osquery/tests" chdir: "src/{{ current_test_repo }}/osquery/tests"
- name: Run ansible-galaxy (osquery) - name: Run ansible-galaxy (osquery)
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-galaxy install --force --ignore-errors --roles-path=/root/ansible25/repositories/roles -r ansible-role-requirements.yml" command: "${HOME}/ansible_venv/bin/ansible-galaxy install --force --ignore-errors --roles-path=${HOME}/ansible_venv/repositories/roles -r ansible-role-requirements.yml"
args: args:
chdir: "src/{{ current_test_repo }}/osquery" chdir: "src/{{ current_test_repo }}/osquery"
- name: Run environment setup - name: Run environment setup
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _key-setup.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _key-setup.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/osquery-logs/ansible-osquery-test-container-setup.log" ANSIBLE_LOG_PATH: "/tmp/osquery-logs/ansible-osquery-test-container-setup.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/osquery/tests" chdir: "src/{{ current_test_repo }}/osquery/tests"
when: when:
@ -127,12 +127,12 @@
- name: Run environment setup - name: Run environment setup
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _container-setup.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i {{ inventory_file }} -e @test-vars.yml _container-setup.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/osquery-logs/ansible-osquery-test-container-setup.log" ANSIBLE_LOG_PATH: "/tmp/osquery-logs/ansible-osquery-test-container-setup.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/osquery/tests" chdir: "src/{{ current_test_repo }}/osquery/tests"
when: when:
@ -148,11 +148,11 @@
- name: Run functional test - name: Run functional test
become: yes become: yes
become_user: root become_user: root
command: "/root/ansible25/bin/ansible-playbook -i tests/{{ inventory_file }} -e @tests/test-vars.yml site.yml" command: "${HOME}/ansible_venv/bin/ansible-playbook -i tests/{{ inventory_file }} -e @tests/test-vars.yml site.yml"
environment: environment:
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action" ANSIBLE_ACTION_PLUGINS: "${HOME}/ansible_venv/repositories/ansible-config_template/action"
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection" ANSIBLE_CONNECTION_PLUGINS: "${HOME}/ansible_venv/repositories/openstack-ansible-plugins/connection"
ANSIBLE_LOG_PATH: "/tmp/osquery-logs/ansible-osquery-test-deployment.log" ANSIBLE_LOG_PATH: "/tmp/osquery-logs/ansible-osquery-test-deployment.log"
ANSIBLE_ROLES_PATH: /root/ansible25/repositories/roles ANSIBLE_ROLES_PATH: "${HOME}/ansible_venv/repositories/roles"
args: args:
chdir: "src/{{ current_test_repo }}/osquery" chdir: "src/{{ current_test_repo }}/osquery"

View File

@ -1,7 +1,7 @@
export ANSIBLE_HOST_KEY_CHECKING="False" export ANSIBLE_HOST_KEY_CHECKING="False"
export ANSIBLE_ROLES_PATH="${HOME}/ansible25/repositories/roles" export ANSIBLE_ROLES_PATH="${HOME}/ansible_venv/repositories/roles"
export ANSIBLE_ACTION_PLUGINS="${HOME}/ansible25/repositories/roles/config_template/action" export ANSIBLE_ACTION_PLUGINS="${HOME}/ansible_venv/repositories/roles/config_template/action"
export ANSIBLE_CONNECTION_PLUGINS="${HOME}/ansible25/repositories/roles/plugins/connection" export ANSIBLE_CONNECTION_PLUGINS="${HOME}/ansible_venv/repositories/roles/plugins/connection"
export ANSIBLE_LOG_PATH="/tmp/osquery-logs/ansible-elk-test.log" export ANSIBLE_LOG_PATH="/tmp/osquery-logs/ansible-elk-test.log"
if [[ ! -d "/tmp/osquery-logs" ]]; then if [[ ! -d "/tmp/osquery-logs" ]]; then
@ -10,7 +10,7 @@ if [[ ! -d "/tmp/osquery-logs" ]]; then
fi fi
echo "To build a test environment run the following:" echo "To build a test environment run the following:"
echo -e "# /root/ansible25/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml tests/test.yml --limit localhost\n" echo -e "# ${HOME}/ansible_venv/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml tests/test.yml --limit localhost\n"
echo "Run manual functional tests by executing the following:" echo "Run manual functional tests by executing the following:"
echo -e "# /root/ansible25/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml site.yml\n" echo -e "# ${HOME}/ansible_venv/bin/ansible-playbook -i tests/inventory/test-container-inventory.yml site.yml\n"

View File

@ -31,15 +31,15 @@ source "${TEST_DIR}/osquery/tests/manual-test.rc"
source "${TEST_DIR}/osquery/bootstrap-embedded-ansible.sh" source "${TEST_DIR}/osquery/bootstrap-embedded-ansible.sh"
deactivate deactivate
${HOME}/ansible25/bin/ansible-galaxy install --force \ ${HOME}/ansible_venv/bin/ansible-galaxy install --force \
--roles-path="${HOME}/ansible25/repositories/roles" \ --roles-path="${HOME}/ansible_venv/repositories/roles" \
--role-file="${TEST_DIR}/osquery/tests/ansible-role-requirements.yml" --role-file="${TEST_DIR}/osquery/tests/ansible-role-requirements.yml"
if [[ ! -e "${TEST_DIR}/osquery/tests/src" ]]; then if [[ ! -e "${TEST_DIR}/osquery/tests/src" ]]; then
ln -s ${TEST_DIR}/../ ${TEST_DIR}/osquery/tests/src ln -s ${TEST_DIR}/../ ${TEST_DIR}/osquery/tests/src
fi fi
${HOME}/ansible25/bin/ansible-playbook -i 'localhost,' \ ${HOME}/ansible_venv/bin/ansible-playbook -i 'localhost,' \
-vv \ -vv \
-e ansible_connection=local \ -e ansible_connection=local \
-e test_clustered_kolide=${CLUSTERED:-no} \ -e test_clustered_kolide=${CLUSTERED:-no} \

View File

@ -21,6 +21,7 @@
post-run: "elk_metrics_6x/tests/post-run.yml" post-run: "elk_metrics_6x/tests/post-run.yml"
files: files:
- ^elk_metrics_6x/.* - ^elk_metrics_6x/.*
- ^bootstrap-embedded-ansible/.*
vars: vars:
osa_test_repo: "openstack/openstack-ansible-ops" osa_test_repo: "openstack/openstack-ansible-ops"
test_clustered_elk: false test_clustered_elk: false
@ -93,6 +94,7 @@
voting: true voting: true
files: files:
- ^osquery/.* - ^osquery/.*
- ^bootstrap-embedded-ansible/.*
- job: - job:
name: "openstack-ansible-ops:osquery-ubuntu-xenial-clustered" name: "openstack-ansible-ops:osquery-ubuntu-xenial-clustered"