Fix AZP tests, add current_container_facts module (#48)

* Add new facts module for determining whether the module is running inside a container or not.

* Add containers to main network.

* Fix running tests locally with newer docker.

* Simplify setup_openssl to only install cryptography.

* Add alias in network.

* Make sure to upgrade cryptography to something more sensible on Ubuntu 16.04.

* Don't jump through hoops for bridge.

* Try to use other IPv4 nets.

* Improve module docs.
This commit is contained in:
Felix Fontein
2020-12-13 09:06:16 +01:00
committed by GitHub
parent 4cc4766ddb
commit fe2d52ff29
13 changed files with 168 additions and 49 deletions
@@ -42,4 +42,4 @@
service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type == 'docker' }}"
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
@@ -31,4 +31,4 @@
service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type == 'docker' }}"
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
@@ -135,3 +135,16 @@
images: "{{ docker_images.stdout_lines | default([]) }}"
when: docker_cli_version is version('0.0', '>')
- name: Detect whether we are running inside a container
current_container_facts:
- name: Inspect current container
docker_container_info:
name: "{{ ansible_module_container_id }}"
register: current_container_info
when: ansible_module_running_in_container
- name: Determine network name
set_fact:
current_container_network_ip: "{{ (current_container_info.container.NetworkSettings.Networks | dictsort)[0].0 | default('') if ansible_module_running_in_container else '' }}"