ansible-config_template/tests/test-connection-plugin.yml
Logan V b819a87394 Add container-aware connection plugin tests
- Test the container awareness of the connection plugin (the lxc-attach
  execution functionality when container_name is set on a host).

- Test delegation to containers

Depends-On: Idb186a061a396713a0e449d47ec262b30d5006ca
Change-Id: I2331d5d5c9cf3d4f8fc83639f6047092232f5887
2017-09-14 04:56:57 +00:00

70 lines
2.2 KiB
YAML

---
# Copyright 2017, Logan Vig <logan2211@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Fail if sshd is running in the containers
hosts: all_containers:alt_containers
gather_facts: no
user: root
become: True
tasks:
- name: Ensure sshd is not running
command: pgrep sshd
register: sshd_pgrep
failed_when: "sshd_pgrep.rc == 0"
changed_when: false
# The container3 ping validates I75f9d0f55ecd875caa1bf608a77c92f950b679a1
- name: Test the connection plugin container awareness functions
hosts: all_containers:alt_containers
gather_facts: no
user: root
become: True
tasks:
- name: Test container ping
action:
module: ping
# Test for I56d8afddbccf01f2944d2fdd505b601a4b048374
- name: Test delegation in the container aware connection plugin
hosts: localhost
gather_facts: no
user: root
become: True
tasks:
- name: Test container delegation without templating
command: cat /etc/hostname
delegate_to: container1
register: delegated
failed_when: delegated.stdout != 'container1'
changed_when: false
- name: Test container delegation using templating
command: cat /etc/hostname
delegate_to: "{{ groups['all_containers'][1] }}"
register: delegated
failed_when: delegated.stdout != 'container2'
changed_when: false
# Test for If594914df53efacc6d5bba148f4f46280f5a117d
- name: Test delegation between container physical_hosts
hosts: fakecontainer
gather_facts: no
user: root
become: True
tasks:
- name: Test delegation between containers on different hosts
action:
module: ping
delegate_to: "{{ groups['all_containers'][0] }}"