Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
61 lines (54 sloc) 1.44 KB
- name: Test playbook
hosts: all
gather_facts: no
tags:
- test-wrapper
- start-containers
tasks:
- name: "Start test container"
delegate_to: localhost
docker_container:
name: "{{ inventory_hostname }}"
image: "{{ docker_image }}"
command: sleep 30m
state: started
recreate: yes
cleanup: yes
detach: true
interactive: true
tty: true
- name: Install python and sudo inside the container
raw: apt -y update && apt install -y python3-minimal python3-urllib3 sudo
- name: Create sudo group
when: user is defined
group:
name: sudo
system: yes
- name: Create user
when: user is defined
user:
name: "{{ user }}"
uid: 1000
groups: adm,sudo
append: yes
- name: No password prompt for sudo group
lineinfile:
dest: /etc/sudoers
regexp: '^%sudo.*'
line: '%sudo ALL=(ALL:ALL) NOPASSWD:ALL'
state: present
validate: 'visudo -cf %s'
- name: "Import {{ playbook }} playbook"
import_playbook: "{{ playbook }}"
- name: "Idempotency check of {{ playbook }} playbook"
import_playbook: "{{ playbook }}"
- hosts: all
tags:
- test-wrapper
- stop-containers
tasks:
- name: "Stop {{ inventory_hostname }} container"
delegate_to: localhost
docker_container:
name: "{{ inventory_hostname }}"
state: absent
You can’t perform that action at this time.