Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dmw'
- Loading branch information
Showing
36 changed files
with
319 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
# `stub_connections/` | ||
|
||
The playbooks in this directory use stub implementations of various third party | ||
tools (kubectl etc.) to verify arguments passed by Ansible to Mitogen and | ||
subsequently onward to the tool result in something that looks sane. | ||
|
||
These are bare minimum tests just to ensure sporadically tested connection | ||
methods haven't broken in embarrasingly obvious ways. |
17 changes: 17 additions & 0 deletions
17
tests/ansible/integration/stub_connections/_end_play_if_not_sudo_linux.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# End the play if we're not on Linux and a raw 'sudo' command isn't available. | ||
# Expects connection:local | ||
|
||
- shell: uname -s | ||
register: out | ||
|
||
- meta: end_play | ||
when: out.stdout != 'Linux' | ||
|
||
- command: sudo -n whoami | ||
args: | ||
warn: false | ||
ignore_errors: true | ||
register: sudo_available | ||
|
||
- meta: end_play | ||
when: sudo_available.rc != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- import_playbook: kubectl.yml | ||
- import_playbook: lxc.yml | ||
- import_playbook: lxd.yml | ||
- import_playbook: setns_lxc.yml | ||
- import_playbook: setns_lxd.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
- name: integration/stub_connections/kubectl.yml | ||
hosts: test-targets | ||
gather_facts: false | ||
any_errors_fatal: true | ||
tasks: | ||
- meta: end_play | ||
when: not is_mitogen | ||
|
||
- meta: end_play | ||
when: ansible_version.full < '2.5' | ||
|
||
- custom_python_detect_environment: | ||
vars: | ||
ansible_connection: kubectl | ||
mitogen_kubectl_path: stub-kubectl.py | ||
register: out | ||
|
||
- assert: | ||
that: | ||
- out.env.THIS_IS_STUB_KUBECTL == '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
- name: integration/stub_connections/lxc.yml | ||
hosts: test-targets | ||
gather_facts: false | ||
any_errors_fatal: true | ||
tasks: | ||
- meta: end_play | ||
when: not is_mitogen | ||
|
||
- custom_python_detect_environment: | ||
vars: | ||
ansible_connection: lxc | ||
mitogen_lxc_attach_path: stub-lxc-attach.py | ||
register: out | ||
|
||
- assert: | ||
that: | ||
- out.env.THIS_IS_STUB_LXC_ATTACH == '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
- name: integration/stub_connections/lxd.yml | ||
hosts: test-targets | ||
gather_facts: false | ||
any_errors_fatal: true | ||
tasks: | ||
- meta: end_play | ||
when: not is_mitogen | ||
|
||
- custom_python_detect_environment: | ||
vars: | ||
ansible_connection: lxd | ||
mitogen_lxc_path: stub-lxc.py | ||
register: out | ||
|
||
- assert: | ||
that: | ||
- out.env.THIS_IS_STUB_LXC == '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# issue #409. | ||
# setns is hard -- it wants to do superuser syscalls, so we must run it in a | ||
# child Ansible via sudo. But that only works if sudo works. | ||
|
||
- name: integration/stub_connections/setns_lxc.yml | ||
hosts: test-targets | ||
gather_facts: false | ||
any_errors_fatal: false | ||
connection: local | ||
tasks: | ||
- meta: end_play | ||
when: not is_mitogen | ||
|
||
- include_tasks: _end_play_if_not_sudo_linux.yml | ||
|
||
- command: | | ||
sudo -nE ansible | ||
-i localhost, | ||
-c setns | ||
-e mitogen_kind=lxc | ||
-e mitogen_lxc_info_path=stub-lxc-info.py | ||
-m shell | ||
-a "echo hi" | ||
localhost | ||
args: | ||
chdir: ../.. | ||
warn: false | ||
register: result | ||
- assert: | ||
that: result.rc == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# issue #409. | ||
# setns is hard -- it wants to do superuser syscalls, so we must run it in a | ||
# child Ansible via sudo. But that only works if sudo works. | ||
|
||
- name: integration/stub_connections/setns_lxd.yml | ||
hosts: test-targets | ||
gather_facts: false | ||
any_errors_fatal: false | ||
connection: local | ||
tasks: | ||
- meta: end_play | ||
when: not is_mitogen | ||
|
||
- include_tasks: _end_play_if_not_sudo_linux.yml | ||
|
||
- command: | | ||
sudo -nE ansible | ||
-i localhost, | ||
-c setns | ||
-e mitogen_kind=lxd | ||
-e mitogen_lxc_path=stub-lxc.py | ||
-m shell | ||
-a "echo hi" | ||
localhost | ||
args: | ||
chdir: ../.. | ||
warn: false | ||
register: result | ||
- assert: | ||
that: result.rc == 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
export ANSIBLE_STRATEGY=mitogen_linear | ||
exec ./run_ansible_playbook.sh "$@" | ||
exec ./run_ansible_playbook.py "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
# Wrap ansible-playbook, setting up some test of the test environment. | ||
|
||
import json | ||
import os | ||
import sys | ||
|
||
|
||
GIT_BASEDIR = os.path.dirname( | ||
os.path.abspath( | ||
os.path.join(__file__, '..', '..') | ||
) | ||
) | ||
|
||
|
||
# Used by delegate_to.yml to ensure "sudo -E" preserves environment. | ||
os.environ['I_WAS_PRESERVED'] = '1' | ||
|
||
# Used by LRU tests. | ||
os.environ['MITOGEN_MAX_INTERPRETERS'] = '3' | ||
|
||
# Add test stubs to path. | ||
os.environ['PATH'] = '%s%s%s' % ( | ||
os.path.join(GIT_BASEDIR, 'tests', 'data', 'stubs'), | ||
os.pathsep, | ||
os.environ['PATH'], | ||
) | ||
|
||
extra = { | ||
'is_mitogen': os.environ.get('ANSIBLE_STRATEGY', '').startswith('mitogen'), | ||
'git_basedir': GIT_BASEDIR, | ||
} | ||
|
||
args = ['ansible-playbook'] | ||
args += ['-e', json.dumps(extra)] | ||
args += sys.argv[1:] | ||
os.execvp(args[0], args) |
Oops, something went wrong.