mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Move interface management into delegate_to test.
This commit is contained in:
parent
7ad003bf68
commit
07e9438848
3 changed files with 41 additions and 9 deletions
|
@ -1,2 +1,3 @@
|
||||||
shippable/posix/group3
|
shippable/posix/group3
|
||||||
needs/ssh
|
needs/ssh
|
||||||
|
needs/root # only on macOS and FreeBSD to configure network interfaces
|
||||||
|
|
|
@ -2,6 +2,46 @@
|
||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
|
platform="$(uname)"
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
if [[ "${platform}" == "FreeBSD" ]] || [[ "${platform}" == "Darwin" ]]; then
|
||||||
|
ifconfig lo0
|
||||||
|
|
||||||
|
existing=$(ifconfig lo0 | grep '^[[:blank:]]inet 127\.0\.0\. ' || true)
|
||||||
|
|
||||||
|
echo "${existing}"
|
||||||
|
|
||||||
|
for i in 3 4 254; do
|
||||||
|
ip="127.0.0.${i}"
|
||||||
|
|
||||||
|
if [[ "${existing}" != *"${ip}"* ]]; then
|
||||||
|
ifconfig lo0 alias "${ip}" up
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ifconfig lo0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown() {
|
||||||
|
if [[ "${platform}" == "FreeBSD" ]] || [[ "${platform}" == "Darwin" ]]; then
|
||||||
|
for i in 3 4 254; do
|
||||||
|
ip="127.0.0.${i}"
|
||||||
|
|
||||||
|
if [[ "${existing}" != *"${ip}"* ]]; then
|
||||||
|
ifconfig lo0 -alias "${ip}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ifconfig lo0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
trap teardown EXIT
|
||||||
|
|
||||||
ANSIBLE_SSH_ARGS='-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null' \
|
ANSIBLE_SSH_ARGS='-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null' \
|
||||||
ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook test_delegate_to.yml -i inventory -v "$@"
|
ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook test_delegate_to.yml -i inventory -v "$@"
|
||||||
|
|
||||||
|
|
|
@ -75,15 +75,6 @@ fi
|
||||||
|
|
||||||
if [ "${platform}" = "freebsd" ] || [ "${platform}" = "osx" ]; then
|
if [ "${platform}" = "freebsd" ] || [ "${platform}" = "osx" ]; then
|
||||||
pip install virtualenv
|
pip install virtualenv
|
||||||
|
|
||||||
# Tests assume loopback addresses other than 127.0.0.1 will work.
|
|
||||||
# Add aliases for loopback addresses used by tests.
|
|
||||||
|
|
||||||
for i in 3 4 254; do
|
|
||||||
ifconfig lo0 alias "127.0.0.${i}" up
|
|
||||||
done
|
|
||||||
|
|
||||||
ifconfig lo0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Since tests run as root, we also need to be able to ssh to localhost as root.
|
# Since tests run as root, we also need to be able to ssh to localhost as root.
|
||||||
|
|
Loading…
Reference in a new issue