Merge "Fix delegation to hosts not in inventory"
This commit is contained in:
commit
c8231e07ca
|
@ -24,8 +24,8 @@ DOCUMENTATION = '''
|
|||
options:
|
||||
container_name:
|
||||
description: Hostname of a container
|
||||
default: inventory_hostname
|
||||
vars:
|
||||
- name: inventory_hostname
|
||||
- name: container_name
|
||||
container_tech:
|
||||
description: Container technology used by a container host
|
||||
|
@ -333,7 +333,9 @@ class Connection(SSH.Connection):
|
|||
super(Connection, self).set_options(task_keys=None, var_options=var_options, direct=direct)
|
||||
|
||||
self.chroot_path = self.get_option('chroot_path')
|
||||
self.container_name = self.get_option('container_name')
|
||||
if var_options and \
|
||||
self.get_option('container_name') == var_options.get('inventory_hostname'):
|
||||
self.container_name = self.get_option('container_name')
|
||||
self.physical_host = self.get_option('physical_host')
|
||||
self.container_tech = self.get_option('container_tech')
|
||||
|
||||
|
|
|
@ -29,3 +29,6 @@ container_networks:
|
|||
properties: {}
|
||||
|
||||
physical_host: localhost
|
||||
|
||||
openssh_server_package: "{{ (ansible_pkg_mgr == 'zypper') | ternary('openssh', 'openssh-server') }}"
|
||||
openssh_server_service: "{{ (ansible_os_family == 'Debian') | ternary('ssh', 'sshd') }}"
|
||||
|
|
|
@ -99,3 +99,34 @@
|
|||
changed_when: false
|
||||
failed_when:
|
||||
- whoami_output.stdout != 'testing'
|
||||
|
||||
# Test for I69f2eed35859bdc149e5ed21441eab7c8a8352cf
|
||||
- name: Reinstall openssh-server for delegation to unknown inventory host
|
||||
hosts: container3
|
||||
tasks:
|
||||
- name: Uninstall OpenSSH server
|
||||
package:
|
||||
name: "{{ openssh_server_package }}"
|
||||
state: absent
|
||||
- name: Install OpenSSH server
|
||||
package:
|
||||
name: "{{ openssh_server_package }}"
|
||||
state: present
|
||||
- name: Start OpenSSH server
|
||||
systemd:
|
||||
name: "{{ openssh_server_service }}"
|
||||
enabled: yes
|
||||
masked: no
|
||||
daemon_reload: yes
|
||||
state: restarted
|
||||
|
||||
- name: Test delegation to host not in inventory
|
||||
hosts: container1
|
||||
remote_user: root
|
||||
tasks:
|
||||
- name: Test container delegation without using inventory name
|
||||
command: cat /etc/hostname
|
||||
delegate_to: 10.100.100.4
|
||||
register: delegated
|
||||
failed_when: delegated.stdout != 'container3'
|
||||
changed_when: false
|
||||
|
|
Loading…
Reference in New Issue