Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2017 Red Hat, Inc. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 13 | # implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | ZUUL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" |
David Moreau Simard | 6ef1d61 | 2018-02-19 23:53:34 -0500 | [diff] [blame^] | 18 | # Initialize tox environment if it's not set up |
| 19 | if [[ ! -d "${ZUUL_DIR}/.tox/venv" ]]; then |
| 20 | pushd $ZUUL_DIR |
| 21 | echo "Virtualenv doesn't exist... creating." |
| 22 | tox -e venv --notest |
| 23 | popd |
| 24 | fi |
| 25 | # Source tox environment |
| 26 | source ${ZUUL_DIR}/.tox/venv/bin/activate |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 27 | |
David Moreau Simard | 6ef1d61 | 2018-02-19 23:53:34 -0500 | [diff] [blame^] | 28 | # Install ARA if it's not installed (not in requirements.txt by default) |
| 29 | python -c "import ara" &> /dev/null |
| 30 | if [ $? -eq 1 ]; then |
| 31 | echo "ARA isn't installed... Installing it." |
| 32 | pip install ara |
| 33 | fi |
| 34 | ARA_DIR=$(dirname $(python3 -c 'import ara; print(ara.__file__)')) |
| 35 | |
| 36 | WORK_DIR=$(mktemp -d /tmp/zuul_logs_XXXX) |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 37 | |
| 38 | if [ -z $1 ] ; then |
| 39 | INVENTORY=$WORK_DIR/hosts.yaml |
| 40 | cat >$INVENTORY <<EOF |
| 41 | all: |
| 42 | hosts: |
| 43 | controller: |
David Moreau Simard | 6ef1d61 | 2018-02-19 23:53:34 -0500 | [diff] [blame^] | 44 | ansible_connection: local |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 45 | node1: |
David Moreau Simard | 6ef1d61 | 2018-02-19 23:53:34 -0500 | [diff] [blame^] | 46 | ansible_connection: local |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 47 | node2: |
David Moreau Simard | 6ef1d61 | 2018-02-19 23:53:34 -0500 | [diff] [blame^] | 48 | ansible_connection: local |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 49 | node: |
| 50 | hosts: |
| 51 | node1: null |
| 52 | node2: null |
| 53 | EOF |
| 54 | else |
| 55 | INVENTORY=$(realpath $1) |
| 56 | fi |
| 57 | |
| 58 | cat >$WORK_DIR/ansible.cfg <<EOF |
| 59 | [defaults] |
David Shrewsbury | 501bd05 | 2017-09-19 14:15:08 -0400 | [diff] [blame] | 60 | inventory = $INVENTORY |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 61 | gathering = smart |
| 62 | gather_subset = !all |
| 63 | fact_caching = jsonfile |
| 64 | fact_caching_connection = ~/.cache/facts |
| 65 | lookup_plugins = $ZUUL_DIR/zuul/ansible/lookup |
| 66 | callback_plugins = $ZUUL_DIR/zuul/ansible/callback:$ARA_DIR/plugins/callbacks |
| 67 | module_utils = $ZUUL_DIR/zuul/ansible/module_utils |
| 68 | stdout_callback = zuul_stream |
| 69 | library = $ZUUL_DIR/zuul/ansible/library |
| 70 | retry_files_enabled = False |
| 71 | EOF |
| 72 | |
| 73 | cd $WORK_DIR |
| 74 | python3 $ZUUL_DIR/zuul/ansible/logconfig.py |
| 75 | export ZUUL_JOB_LOG_CONFIG=$WORK_DIR/logging.json |
| 76 | export ARA_DIR=$WORK_DIR/.ara |
| 77 | export ARA_LOG_CONFIG=$ZUUL_JOB_LOG_CONFIG |
| 78 | rm -rf $ARA_DIR |
| 79 | ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/fixtures/test-stream.yaml |
| 80 | ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/fixtures/test-stream-failure.yaml |
David Moreau Simard | 6ef1d61 | 2018-02-19 23:53:34 -0500 | [diff] [blame^] | 81 | # ansible-playbook $ZUUL_DIR/playbooks/zuul-stream/functional.yaml |
Monty Taylor | e5b614e | 2017-09-01 12:56:57 -0500 | [diff] [blame] | 82 | echo "Logs are in $WORK_DIR" |