Fix network_cli test to use a trap for cleanup (#69762)

Signed-off-by: Rick Elrod <rick@elrod.me>
pull/69769/head
Rick Elrod 5 years ago committed by GitHub
parent 53f9822e75
commit 61a1fe1d7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
- hosts: vyos-1-1-8
- hosts: vyos
gather_facts: false
tasks:

@ -1,7 +1,13 @@
#!/usr/bin/env bash
set -ux # no -e because we want to run teardown no matter waht
set -eux
export ANSIBLE_ROLES_PATH=../
function cleanup {
ansible-playbook teardown.yml -i "$INVENTORY_PATH" "$@"
}
trap cleanup EXIT
ansible-playbook setup.yml -i "$INVENTORY_PATH" "$@"
# We need a nonempty file to override key with (empty file gives a
@ -9,11 +15,13 @@ ansible-playbook setup.yml -i "$INVENTORY_PATH" "$@"
foo=$(mktemp)
echo hello > "$foo"
# We want to ensure that passwords make it to the network connection plugins
# because they follow a different path than the rest of the codebase.
# In setup.yml, we create a passworded user, and now we connect as that user
# to make sure the password we pass here successfully makes it to the plugin.
ansible-playbook \
-i "$INVENTORY_PATH" \
-e ansible_user=atester \
-e ansible_password=testymctest \
-e ansible_ssh_private_key_file="$foo" \
passworded_user.yml
ansible-playbook teardown.yml -i "$INVENTORY_PATH" "$@"

@ -1,4 +1,4 @@
- hosts: vyos-1-1-8
- hosts: vyos
connection: ansible.netcommon.network_cli
become: true
gather_facts: false

@ -1,4 +1,4 @@
- hosts: vyos-1-1-8
- hosts: vyos
connection: ansible.netcommon.network_cli
become: true
gather_facts: false

Loading…
Cancel
Save