-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.yaml
59 lines (49 loc) · 1.75 KB
/
base.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
- name: Create Docker Container
hosts: localhost
connection: local
remote_user: root
tasks:
- name: include variables
include_vars: base_vars.yml
- name: Install python-docker on Red Hat based distribution
yum:
name: python-docker
enablerepo: extras
state: latest
when: ansible_os_family == 'RedHat'
- name: Install python-docker on Debian based distribution
apt:
name: python-docker
update_cache: yes
when: ansible_os_family == 'Debian'
- name: Create Container
docker_container:
name: "{{ name }}"
image: "{{ image }}"
state: started
command: ["sleep", "infinity"]
privileged: "{{ privileged }}"
- name: Check container type CentOS
command: '/bin/sh check_OS.sh "{{ name }}"'
register: resultCentOS
ignore_errors: True
- name: CentOS Install epel-release
command: docker exec "{{ name }}" bash -l -c 'yum install epel-release -y'
when: resultCentOS is succeeded
- name: CentOS Install nginx
command: docker exec "{{ name }}" bash -l -c 'yum install nginx -y'
when: resultCentOS is succeeded
- name: Check container type Debian
command: '/bin/sh check_OS_debian.sh "{{ name }}"'
register: resultDebian
ignore_errors: True
- name: Debian apt-get update
command: docker exec "{{ name }}" bash -l -c 'apt-get update'
when: resultDebian is succeeded
- name: Debian apt-get upgrade
command: docker exec "{{ name }}" bash -l -c 'apt-get upgrade -y'
when: resultDebian is succeeded
- name: Debian Install nginx
command: docker exec "{{ name }}" bash -l -c 'apt-get install nginx -y'
when: resultDebian is succeeded