Initial rough commit to save the code before cleanup

This commit is contained in:
tanshu
2020-04-03 09:24:02 +05:30
commit e0e7b07468
29 changed files with 942 additions and 0 deletions

17
gitea/files/nginx.conf.j2 Normal file
View File

@ -0,0 +1,17 @@
server {
listen 80;
server_name {{ http_host }};
# location /_/static {
# alias /path/to/gitea/public;
# }
location / {
proxy_pass http://localhost:3000;
}
}

62
gitea/playbook-pg.yml Executable file
View File

@ -0,0 +1,62 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/default.yml
tasks:
- name: Add the user 'git' with a specific uid and a primary group of 'admin'
user:
name: "{{ user }}"
comment: Git user
create_home: no
- name: Pull Gitea image
docker_image:
name: "{{ container_image }}"
source: pull
- getent:
database: passwd
key: "{{ user }}"
split: ":"
- name: Create gitea container
docker_container:
name: "{{ container_name }}"
image: "{{ container_image }}"
state: started
env:
USER_UID: "{{ getent_passwd[user][1] }}"
USER_GID: "{{ getent_passwd[user][2] }}"
DB_TYPE: "{{ db_type }}"
DB_HOST: "{{ db_host }}"
DB_NAME: "{{ db_name }}"
DB_USER: "{{ db_user }}"
DB_PASSWD: "{{ db_password }}"
ROOT_URL: "{{ http_url }}"
links:
- "postgres:db"
published_ports:
- "3000:3000"
- "127.0.0.1:2222:22"
volumes:
- /var/lib/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
# - name: Sets Nginx conf file for gitea
# template:
# src: "files/nginx.conf.j2"
# dest: "/etc/nginx/sites-available/{{ http_conf }}"
# - name: Enables new site
# file:
# src: "/etc/nginx/sites-available/{{ http_conf }}"
# dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
# state: link
# notify: Reload Nginx

54
gitea/playbook.yml Executable file
View File

@ -0,0 +1,54 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/default.yml
tasks:
- name: Add the user 'git' with a specific uid and a primary group of 'admin'
user:
name: "{{ user }}"
comment: Git user
create_home: no
- name: Pull Gitea image
docker_image:
name: "{{ container_image }}"
source: pull
- getent:
database: passwd
key: "{{ user }}"
split: ":"
- name: Create gitea container
docker_container:
name: "{{ container_name }}"
image: "{{ container_image }}"
state: started
env:
USER_UID: "{{ getent_passwd[user][1] }}"
USER_GID: "{{ getent_passwd[user][2] }}"
published_ports:
- "3000:3000"
- "127.0.0.1:2222:22"
volumes:
- /var/lib/gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
# - name: Sets Nginx conf file for gitea
# template:
# src: "files/nginx.conf.j2"
# dest: "/etc/nginx/sites-available/{{ http_conf }}"
# - name: Enables new site
# file:
# src: "/etc/nginx/sites-available/{{ http_conf }}"
# dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
# state: link
# notify: Reload Nginx

46
gitea/readme.md Normal file
View 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).

15
gitea/vars/default-pg.yml Normal file
View File

@ -0,0 +1,15 @@
---
http_host: "git.tanshu.com"
http_conf: "git.tanshu.com.conf"
http_url: "https://git.tanshu.com"
container_name: gitea
container_image: gitea/gitea
user: 'git'
db_type: 'postgres'
db_host: 'db:5432'
db_name: 'gitea'
db_user: 'postgres'
db_password: '123456'

9
gitea/vars/default.yml Normal file
View File

@ -0,0 +1,9 @@
---
http_host: "git.tanshu.com"
http_conf: "git.tanshu.com.conf"
http_url: "https://git.tanshu.com"
container_name: gitea
container_image: gitea/gitea
user: 'git'