Skip to content

Instantly share code, notes, and snippets.

@dmsimard
Created June 22, 2018 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmsimard/e3716a1d6f1e97e787aeb4e016d0fd6a to your computer and use it in GitHub Desktop.
Save dmsimard/e3716a1d6f1e97e787aeb4e016d0fd6a to your computer and use it in GitHub Desktop.
ara-log-reproducer
# bash test.sh 2.5.5
New python executable in /tmp/venv/bin/python
Installing setuptools, pip, wheel...done.
Installing ansible==2.5.5...
Running playbook without ARA...
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Logged results:
2018-06-22 15:36:06,187 p=3077 u=root | [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
2018-06-22 15:36:06,187 p=3077 u=root | [WARNING]: No inventory was parsed, only implicit localhost is available
2018-06-22 15:36:06,190 p=3077 u=root | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
2018-06-22 15:36:06,506 p=3077 u=root | PLAY [localhost] ****************************************************************************************************************************************************************************************************
2018-06-22 15:36:06,517 p=3077 u=root | TASK [Test] *********************************************************************************************************************************************************************************************************
2018-06-22 15:36:06,543 p=3077 u=root | ok: [localhost] => {
"msg": "test"
}
2018-06-22 15:36:06,545 p=3077 u=root | PLAY RECAP **********************************************************************************************************************************************************************************************************
2018-06-22 15:36:06,545 p=3077 u=root | localhost : ok=1 changed=0 unreachable=0 failed=0
Installing ARA...
Running playbook with ARA...
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Logged results:
2018-06-22 15:36:20,786 p=3104 u=root | [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
2018-06-22 15:36:20,786 p=3104 u=root | [WARNING]: No inventory was parsed, only implicit localhost is available
2018-06-22 15:36:20,789 p=3104 u=root | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
+--------------------------------------+------------------------+---------------------+----------+----------+-----------------+
| ID | Path | Time Start | Duration | Complete | Ansible Version |
+--------------------------------------+------------------------+---------------------+----------+----------+-----------------+
| 4a030d7e-9ee7-4492-9bd7-70084b97f97b | /tmp/venv/playbook.yml | 2018-06-22 15:36:21 | 0:00:00 | True | 2.5.5 |
+--------------------------------------+------------------------+---------------------+----------+----------+-----------------+
#!/bin/bash
function run_playbook() {
ansible-playbook /tmp/venv/playbook.yml 2>&1>/dev/null
echo
echo
echo "Logged results:"
cat $ANSIBLE_LOG_PATH
echo
echo
rm -f $ANSIBLE_LOG_PATH
}
if [ -z "${1}" ]; then
echo "Script needs an Ansible version number as an argument."
echo "Example: ${0} 2.5.5"
exit 1
fi
# Clean up
rm -rf /tmp/venv
rm -rf ~/.ara
# Source a new venv
virtualenv /tmp/venv
source /tmp/venv/bin/activate
echo "Installing ansible==${1}..."
pip install ansible==${1} 2>&1>/dev/null
cat << EOF > /tmp/venv/playbook.yml
- hosts: localhost
gather_facts: no
tasks:
- name: Test
debug:
msg: test
EOF
export ANSIBLE_LOG_PATH=/tmp/venv/ansible.log
echo "Running playbook without ARA..."
run_playbook
echo "Installing ARA..."
pip install ara 2>&1>/dev/null
export ANSIBLE_CALLBACK_PLUGINS=$(python -m ara.setup.callback_plugins)
echo "Running playbook with ARA..."
run_playbook
ara playbook list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment