1
0
mirror of https://github.com/jcwimer/startup-infrastructure synced 2026-03-24 22:34:42 +00:00

Created shell, ansible-dependencies, common, and gitea roles

This commit is contained in:
2018-07-27 00:59:24 +00:00
parent 090805b618
commit 2490fba2a2
15 changed files with 320 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
---
- name: Install package dependencies
raw: apt-get update -qq && apt-get install -y python-simplejson python-urllib3 python-openssl python-pyasn1 python-pip ca-certificates
- name: Install pip dependencies
raw: pip install ndg-httpsclient
ignore_errors: true
- name: Install pip dependencies again because it fails sometimes
raw: pip install ndg-httpsclient
ignore_errors: true

101
roles/common/tasks/main.yml Normal file
View File

@@ -0,0 +1,101 @@
---
# This playbook contains plays that will run on all nodes
- name: Add docker key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add docker repo
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
state: present
- name: Update apt
apt: update_cache=yes
#- name: Upgrade APT to the lastest packages
# apt: upgrade=dist
- name: Install standard programs
apt: name={{ item }} state=present force=yes
with_items:
- htop
- curl
- openssh-server
- git
- rsync
- zip
- unzip
- fail2ban
- ntp
- mysql-client
- wget
- nfs-common
- docker-ce={{docker_ce_version_to_install}}
- sshpass
- ack-grep
- dnsutils
- nmon
- build-essential
- tmux
- name: Create standard user
user:
name: "{{ standard_user }}"
groups:
- sudo
- docker
state: present
shell: /bin/bash
- name: Add standard_user to docker group
user:
name: "{{ standard_user }}"
groups: docker
append: yes
- name: Set authorized key took from url
become: yes
become_user: "{{ standard_user }}"
authorized_key:
user: "{{ standard_user }}"
state: present
key: "{{ home_pub_key }}"
- name: Docker compose version
get_url:
url: "https://github.com/docker/compose/releases/download/{{docker_compose_version_to_install}}/docker-compose-{{ ansible_system }}-{{ ansible_userspace_architecture }}"
dest: /usr/local/bin/docker-compose
validate_certs: false
mode: 755
group: docker
- name: Set timezone to NewYork
timezone:
name: "{{ chosen_timezone }}"
ignore_errors: true
- name: Replace sudoers file
template: src=../roles/common/templates/sudoers.j2 dest=/etc/sudoers
- name: Create /etc/docker
file:
path: /etc/docker
group: root
owner: root
mode: 700
state: directory
- name: Replace docker daemon file
template: src=../roles/common/templates/docker-daemon.json.j2 dest=/etc/docker/daemon.json
register: dockerdaemon
- name: Restart docker if daemon changes
service:
name: docker
state: restarted
when: dockerdaemon.changed
- name: Creates directory
file: path=/data state=directory

View File

@@ -0,0 +1,5 @@
{
"insecure-registries" : ["{{ registry_location }}","10.0.0.221:5000"],
"metrics-addr" : "0.0.0.0:9323",
"experimental" : true
}

View File

@@ -0,0 +1,30 @@
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL) NOPASSWD:ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d

View File

@@ -0,0 +1,6 @@
---
- name: Replace sudoers file
template: src=../roles/gitea/templates/docker-compose.yml.j2 dest=/data/gitea.yml
- name: Run docker-compose
shell: cd /data && docker-compose -f gitea.yml up -d

View File

@@ -0,0 +1,28 @@
version: '2'
services:
web:
image: gitea/gitea:1.3.2
volumes:
- ./data:/data
ports:
- "80:3000"
- "2222:22"
restart: always
# networks:
# - db
# depends_on:
# - db
# db:
# image: mariadb:10
# restart: always
# networks:
# - db
# environment:
# - MYSQL_ROOT_PASSWORD=changeme
# - MYSQL_DATABASE=gitea
# - MYSQL_USER=gitea
# - MYSQL_PASSWORD=changeme
# volumes:
# - ./db/:/var/lib/mysql
#networks:
# db: