Initial rough commit to save the code before cleanup
This commit is contained in:
2
postgres/files/info.php.j2
Normal file
2
postgres/files/info.php.j2
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
19
postgres/files/nginx.conf.j2
Normal file
19
postgres/files/nginx.conf.j2
Normal file
@ -0,0 +1,19 @@
|
||||
server {
|
||||
listen {{ http_port }};
|
||||
root /var/www/html;
|
||||
index index.php index.html index.htm index.nginx-debian.html;
|
||||
server_name {{ http_host }};
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
32
postgres/playbook.yml
Executable file
32
postgres/playbook.yml
Executable file
@ -0,0 +1,32 @@
|
||||
#################################################
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
|
||||
tasks:
|
||||
- name: Pull default Postgresql image
|
||||
docker_image:
|
||||
name: "{{ postgres_image }}"
|
||||
source: pull
|
||||
|
||||
# Creates the number of containers defined by the variable create_containers, using values from vars file
|
||||
- name: Create postgres container
|
||||
docker_container:
|
||||
name: "{{ postgres_name }}"
|
||||
image: "{{ postgres_image }}"
|
||||
state: started
|
||||
env:
|
||||
POSTGRESQL_USER: "{{ pg_user }}"
|
||||
POSTGRESQL_PASSWORD: "{{ pg_password }}"
|
||||
POSTGRESQL_DATABASE: 'postgres'
|
||||
PGDATA: '/var/lib/postgresql/data/pgdata'
|
||||
exposed_ports:
|
||||
- 5432
|
||||
published_ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- /var/lib/postgresql/data:/var/lib/postgresql/data
|
||||
46
postgres/readme.md
Normal file
46
postgres/readme.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Docker on Ubuntu 18.04
|
||||
|
||||
This playbook will install Docker an Ubuntu 18.04 machine, as explained in the guide on
|
||||
[How to Use Ansible to Install and Set Up Docker on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-install-and-set-up-docker-on-ubuntu-18-04).
|
||||
A number of containers will be created with the options specified in the `vars/default.yml` variable file.
|
||||
|
||||
## Settings
|
||||
|
||||
- `create_containers`: number of containers to create.
|
||||
- `default_container_name`: default name for new containers.
|
||||
- `default_container_image`: default image for new containers.
|
||||
- `default_container_command`: default command to run on new containers.
|
||||
|
||||
|
||||
## Running this Playbook
|
||||
|
||||
Quick Steps:
|
||||
|
||||
### 1. Obtain the playbook
|
||||
```shell
|
||||
git clone https://github.com/do-community/ansible-playbooks.git
|
||||
cd ansible-playbooks/docker_ubuntu1804
|
||||
```
|
||||
|
||||
### 2. Customize Options
|
||||
|
||||
```shell
|
||||
nano vars/default.yml
|
||||
```
|
||||
|
||||
```yml
|
||||
#vars/default.yml
|
||||
---
|
||||
create_containers: 4
|
||||
default_container_name: docker
|
||||
default_container_image: ubuntu
|
||||
default_container_command: sleep 1d
|
||||
```
|
||||
|
||||
### 3. Run the Playbook
|
||||
|
||||
```command
|
||||
ansible-playbook -l [target] -i [inventory file] -u [remote user] playbook.yml
|
||||
```
|
||||
|
||||
For more information on how to run this Ansible setup, please check this guide: [How to Use Ansible to Install and Set Up Docker on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-install-and-set-up-docker-on-ubuntu-18-04).
|
||||
7
postgres/vars/default.yml
Normal file
7
postgres/vars/default.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
postgres_name: postgres
|
||||
postgres_image: postgres
|
||||
pg_user: postgres
|
||||
pg_password: '123456'
|
||||
data_location: /var/lib/postgresql/data
|
||||
|
||||
Reference in New Issue
Block a user