Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/registry drone roles #42

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/create_gandi_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ gandi vm create --memory 1024 --hostname worker1 --image "Debian 8" --size 10G -
# SMTP
# vlan ip range for smtp services : 192.168.1.32/29
gandi vm create --memory 2048 --hostname mail1 --image "Debian 8" --size 20G --datacenter FR-SD3 --vlan alpha_vlan --ip 192.168.1.33 --ip-version 4

# Registry
gandi vm create --memory 4096 --cpu 2 --hostname registry1 --image "Debian 8" --size 50G --datacenter FR-SD3 --ip-version 4
7 changes: 7 additions & 0 deletions deploy-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- hosts: registry
roles:
- common-no-vlan
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This role is useless at the moment, only needed for ssh keys, maybe in the future it will be of more use.

- docker
- nginx
- registry
- drone
24 changes: 23 additions & 1 deletion hosts.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ caliopen
gateway
storage
smtp
citools

[services:vars]
dist_directory=./dist
object_store_access_key=SZ1BBGKTD2N13E0W5L8N
object_store_secret_key=qTsjiThBQA2NH6ZO32tCwCC6wcC8ValVLR16XUsB
caliopen_domain_name=alpha.caliopen.org
caliopen_domain_base=caliopen.org
caliopen_domain_name=alpha.{{ caliopen_domain_base }}
caliopen_nameservers=["155.133.128.67", "155.133.128.65"]

# Vault
Expand All @@ -20,6 +22,20 @@ vault_worker_password=TO_BE_DEFINED
vault_cert_path=/etc/vault/alpha.caliopen.org.crt
vault_key_path=/etc/vault/alpha.caliopen.org.key

# Docker registry
registry_path=/etc/docker-registry

# Drone
drone_path=/etc/drone
# Github OAuth
DRONE_GITHUB_CLIENT=
DRONE_GITHUB_SECRET=
# Agent/Server communication
DRONE_SECRET=this_should_be_a_secret
# List of admins, Github usernames
DRONE_ADMIN=
DRONE_HOST=drone.{{ caliopen_domain_base }}

# Version of installed software out of host packaging

# monitoring platform
Expand Down Expand Up @@ -61,6 +77,9 @@ cache
mq
object_store

[citools:children]
registry

[store]
store1 ansible_host=ip_store1 ansible_user=root backend_ip=backend_store1
store2 ansible_host=ip_store2 ansible_user=root backend_ip=backend_store2
Expand Down Expand Up @@ -107,3 +126,6 @@ mail1 ansible_host=ip_mail1 ansible_user=root backend_ip=backend_mail1

[logstash]
logstash1 ansible_host=ip_logstash1 ansible_user=root backend_ip=backend_logstash1

[registry]
registry1 ansible_host=ip_registry1 ansible_user=root backend_ip=backend_registry1
8 changes: 8 additions & 0 deletions roles/common-no-vlan/files/ssh_authorized_keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5+2ViaP1ktWlzMCY4IOJOV1K0TH1GstHzoMdeIf9ihiSz7nR7wKcYJMC6KlmOYVQzftENXHQZAtbL4tVPLpLWXN+4fCn+pbQVu47P3QCH9Ez0d23p4byZl5h+qyx0dJv/ltc71X6NIvHH2WXmvvy+Bda4b1NVpJN/voiMoihipsjPPeL+s6B+3dw6PD3h5vvzvJCrfkKGijoT74+BbjYimwmNsaDRQH9tIMaTVeV7ZIe9qfxg5fkg4WsFl9mzikbqYzdBgiC2XeK/L4w3FJONALAEy7FTsUdNaenKxTn4zw/9qdV20TqYEyCbYlANS+2NMLYxeSqdpYB3yvePoucOw== [email protected]
ssh-dss AAAAB3NzaC1kc3MAAACBAM686CNkUeMiHvr/1tj4zRaJM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J1ZXAD0tLv3Fsj1KHNQi8da+P0ph33XeplCGPhRBohiL3obxWSDZ/WX0MaX4tgICqDHAkSGrDJkeF8dgNAtO2+m44oty6U/ztnuSKQGBXACxbpS+M8YfPFTyBkjrOtfqk0R/MgdG2gxvPyYPG3ody20QcYzTbG9LrtOReN58kPt4D/3Mp2w== [email protected]
7 changes: 7 additions & 0 deletions roles/common-no-vlan/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- name: install ssh authorized keys
copy: src=ssh_authorized_keys dest=/root/.ssh/authorized_keys mode=0600
tags:
- ssh

- name: upgrade packages
shell: apt-get upgrade -y
39 changes: 39 additions & 0 deletions roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
- name: install dependencies
apt: package={{ item }} state=installed update_cache=yes
with_items:
- apt-transport-https
- curl
- ca-certificates
- gnupg2
- software-properties-common

- name: add apt key
apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present

- name: get codename
shell: lsb_release -cs
register: debian_codename

- name: Add docker apt repo
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ debian_codename.stdout }} stable"
filename: docker
state: present

- name: install docker ce
apt: package={{ item }} update_cache=yes
with_items:
- docker-ce

- name: start docker
service:
name: docker
state: restarted

- name: install docker compose
get_url:
url: https://github.com/docker/compose/releases/download/1.22.0/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 0550
20 changes: 20 additions & 0 deletions roles/drone/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: create drone directory
file:
path: "{{ drone_path }}"
state: directory

- name: copy compose file for registry server
template: src=docker-compose.yml.j2 dest={{ drone_path }}/docker-compose.yml

- name: start drone
shell: docker-compose -f {{ drone_path }}/docker-compose.yml up -d

- name: configure nginx vhost
template:
src: drone.nginx.j2
dest: /etc/nginx/sites-enabled/drone

- name: restart service nginx
service:
name: nginx
state: restarted
33 changes: 33 additions & 0 deletions roles/drone/templates/docker-compose.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '2'

services:

drone-server:
image: drone/drone
ports:
- 8000:8000
- 9000
volumes:
- ./drone/:/var/lib/drone/
restart: always
environment:
- DRONE_OPEN=true
- DRONE_HOST={{ DRONE_HOST }}
- DRONE_GITHUB=true
- DRONE_ORGS=CaliOpen
- DRONE_GITHUB_CLIENT={{ DRONE_GITHUB_CLIENT }}
- DRONE_GITHUB_SECRET={{ DRONE_GITHUB_SECRET }}
- DRONE_SECRET={{ DRONE_SECRET }}
- DRONE_ADMIN={{ DRONE_ADMIN }}

drone-agent:
image: drone/agent
command: agent
restart: always
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_SERVER=drone-server:9000
- DRONE_SECRET={{ DRONE_SECRET }}
29 changes: 29 additions & 0 deletions roles/drone/templates/drone.nginx.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
upstream drone {
server 127.0.0.1:8000;
}

server {
listen 443 ssl;
listen [::]:443 ssl;
server_name drone.{{ caliopen_domain_base }};

ssl_certificate /etc/nginx/certs/{{ caliopen_domain_base }}.crt;
ssl_certificate_key /etc/nginx/certs/{{ caliopen_domain_base }}.key;
ssl_prefer_server_ciphers On;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS;
ssl_session_cache shared:SSL:10m;

location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;

proxy_pass http://drone;
proxy_redirect off;
proxy_http_version 1.1;
proxy_buffering off;

chunked_transfer_encoding off;
}
}
89 changes: 0 additions & 89 deletions roles/nginx/files/caliopen.key

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-----BEGIN CERTIFICATE-----
MIIE/TC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bQ7CG9XbXSzWm+ZB66VYMZjQg8h1nC/I1mPA1D6J2IvMhwZYvukOlarH/o0+
5Dq1B5LLsI4i1EVnbHEwg2a8HqgB1xvBjSieXs7JSCulLphd37HInaLvhan76l34
EqNISm/xqIWpge/Dg1VxKe9p7WWlNj/EQH2e56Pn8i9f
CSqGSIb3DQEBCwUAA4IBAQBIp+2X3cN7EHUXcz8cLp/9sP05PAz/HIEawdkX/muv
uWEctln2Pdg2YR3GWaCVFYAIOOaTpG5gFFysQ9E0d7hex4obKaWMeMFjw3aJMXcN
P1WO6YL3zgabeK+C4+ZupMhrS/G4hw3dIIDE54YXtY4NidkPE+9cvhMNWgNQvLdT
irDqRMX+dNt0BKVksXty2F++Y+zdOeEUHnI/l4A09Q0b4bxGX4cwjGydDUR+3uKF
6YGyTqOtXXd1z8sR0oUmUDEBk0XFWqSU+zLrqfhaSUcIvykdKBHPOphWE3g1xxrB
fWA/1c0//CFBR++Q5LcO1tFiWkZKJBdq1LPbtQIcuVdc
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIF6TCCA9GgAwIBAgIQBeTcO5Q4qzuFl8umoZhQ4zANBgkqhkiG9w0BAQwFADCB
Expand Down Expand Up @@ -92,5 +92,4 @@ YzYhBx9G/2CkkeFnvN4ffhkUyWNnkepnB2u0j4vAbkN9w6GAbLIevFOFfdyQoaS8
Le9Gclc1Bb+7RrtubTeZtv8jkpHGbkD4jylW6l/VXxRTrPBPYer3IsynVgviuDQf
Jtl7GQVoP7o81DgGotPmjw7jtHFtQELFhLRAlSv0ZaBIefYdgWOWnU914Ph85I6p
0fKtirOMxyHNwu8=
-----END CERTIFICATE-----

-----END CERTIFICATE-----
Loading