-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparam_container_dep.yml
115 lines (94 loc) · 3.41 KB
/
param_container_dep.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
- hosts: webserver
become: true
#become_user: sudo
#ansible_user: root
#ansible_password: root123
#ansible_connection: ssh
#ansible_user: root
#ansible_ssh_pass: root123
gather_facts: false
ignore_errors: yes
vars:
create_containers: 1
default_container_name: mysqldemo_test_03_12_2020
default_container_image: ubuntu
default_container_command: sleep 1d
tasks:
- name: Install aptitude using apt
apt: name=aptitude state=latest
- name: Install required system packages
apt: name={{ item }} state=latest update_cache=yes
loop: [ 'apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common', 'python3-pip', 'virtu
alenv', 'python3-setuptools']
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu xenial stable
state: present
- name: Update apt and install docker-ce
apt: update_cache=yes name=docker-ce state=latest
- name: Install Docker Module for Python
pip:
name: docker
- name: Pull default Docker image
docker_image:
name: "{{ default_container_image }}"
source: pull
- name: Create default containers
docker_container:
name: "{{ default_container_name }}{{ item }}"
image: "{{ default_container_image }}"
command: "{{ default_container_command }}"
state: present
with_sequence: count={{ create_containers }}
# - name: Accessing Docker container
# docker:
# name: [container-name]
# image: [image-ive-created-container-with-on-server]
# state: present
# command: docker container run -it ubuntu /bin/bash
- name: list of containers using shell
shell: docker ps -a
#- name: list of containers using docker module
#docker_container:
#name: new_test_2_12_2020
#image: ubuntu
#state: present
#command: docker ps -a
- name: Start Docker container
shell: docker container start mysqldemo_test_03_12_2020
#- name: Start Docker container
#docker_container:
#name: new_test_2_12_2020
#image: ubuntu
#state: present
#command: docker container start new_test_2_12_2020
- name: Accessing Docker container
shell: docker exec -it mysqldemo_test_03_12_2020 /bin/bash
#- name: Accessing Docker container
#docker_container:
#name: new_test_2_12_2020
#image: ubuntu
#state: present
#command: docker exec -it new_test_2_12_2020 /bin/bash
- name: Run update command
shell: apt update
#- name: Run update command
#shell: apt upgrade
- name: Install mysql-server
shell: apt-get install mysql-server
#- name: Install required mysql server
#apt: name={{ item }} state=latest update_cache=yes
#loop: [ 'update', 'upgrade', 'mysql-server', 'systemctl']
- name: Start Mysql server
command: /etc/init.d/mysql start
- name: Login to Mysql Server
command: mysql
- name: Create Mysql database
shell: create database test_project;
- name: View the current mysql schemas/databases
shell: show schemas;