Skip to content

Commit

Permalink
Merge pull request #18 from Diesel-Net/development
Browse files Browse the repository at this point in the history
Resolves #9
  • Loading branch information
tomdaley92 authored May 16, 2021
2 parents 398aee8 + 5df19ad commit 53c5a8f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .ansible/inventory/development/group_vars/all/main.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
env: "dev"
env: dev
auto_reboots: yes
3 changes: 2 additions & 1 deletion .ansible/inventory/production/group_vars/all/main.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
env: "prod"
env: prod
auto_reboots: no
3 changes: 2 additions & 1 deletion .ansible/inventory/stable/group_vars/all/main.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
env: "test"
env: test
auto_reboots: yes
4 changes: 4 additions & 0 deletions .ansible/roles/requirements.update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: ubuntu_base
scm: git
src: "[email protected]:Diesel-Net/ansible-role-ubuntu-base.git"
version: 1.2.0
10 changes: 10 additions & 0 deletions .ansible/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ansible-galaxy install -r .ansible/roles/requirements.update.yaml -p .ansible/roles --force
# ansible-playbook .ansible/update.yaml -i .ansible/inventory/development/hosts --vault-id ~/.tokens/master_id

- hosts: all
strategy: free
tasks:

- import_role:
name: ubuntu_base
tasks_from: update
94 changes: 35 additions & 59 deletions .drone.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
kind: pipeline
type: docker
name: development pipeline
name: main deployment pipeline

clone:
depth: 1
Expand All @@ -18,11 +18,16 @@ steps:
settings:
galaxy: .ansible/roles/requirements.ssh.yaml
playbook: .ansible/configure_ssh.yaml
inventory: .ansible/inventory/development/hosts
private_key:
from_secret: ansible_private_key
vault_password:
from_secret: ansible_vault_password
from_secret: ansible_vault_password
commands:
# dynamically select inventory based on Git branch/tag
- version=$DRONE_BRANCH
- if [ ! -z $DRONE_TAG ]; then version=production; fi
- /bin/drone-ansible --inventory .ansible/inventory/$$version/hosts


- name: deploy
image: plugins/ansible:3
Expand All @@ -31,105 +36,76 @@ steps:
settings:
galaxy: .ansible/roles/requirements.deploy.yaml
playbook: .ansible/deploy.yaml
inventory: .ansible/inventory/development/hosts
private_key:
from_secret: ansible_private_key
vault_password:
from_secret: ansible_vault_password
commands:
# dynamically select inventory based on Git branch/tag
- version=$DRONE_BRANCH
- if [ ! -z $DRONE_TAG ]; then version=production; fi
- /bin/drone-ansible --inventory .ansible/inventory/$$version/hosts

trigger:
branch:
- development
- stable
event:
- push
- tag

---

kind: pipeline
type: docker
name: test pipeline
name: daily updates pipeline

clone:
depth: 1

steps:
- name: configure ssh
- name: Update development server(s)
image: plugins/ansible:3
environment:
ANSIBLE_CONFIG: .ansible/ansible.cfg
SUPER_USER:
from_secret: super_user
SUPER_PASS:
from_secret: super_pass
settings:
galaxy: .ansible/roles/requirements.ssh.yaml
playbook: .ansible/configure_ssh.yaml
inventory: .ansible/inventory/stable/hosts
galaxy: .ansible/roles/requirements.update.yaml
playbook: .ansible/update.yaml
inventory: .ansible/inventory/development
private_key:
from_secret: ansible_private_key
vault_password:
from_secret: ansible_vault_password

- name: deploy
image: plugins/ansible:3
environment:
ANSIBLE_CONFIG: .ansible/ansible.cfg
settings:
galaxy: .ansible/roles/requirements.deploy.yaml
playbook: .ansible/deploy.yaml
inventory: .ansible/inventory/stable/hosts
private_key:
from_secret: ansible_private_key
vault_password:
from_secret: ansible_vault_password


trigger:
branch:
- stable
event:
- push

---
kind: pipeline
type: docker
name: production pipeline
from_secret: ansible_vault_password

clone:
depth: 1

steps:
- name: configure ssh
- name: Update test server(s)
image: plugins/ansible:3
environment:
ANSIBLE_CONFIG: .ansible/ansible.cfg
SUPER_USER:
from_secret: super_user
SUPER_PASS:
from_secret: super_pass
settings:
galaxy: .ansible/roles/requirements.ssh.yaml
playbook: .ansible/configure_ssh.yaml
inventory: .ansible/inventory/production/hosts
galaxy: .ansible/roles/requirements.update.yaml
playbook: .ansible/update.yaml
inventory: .ansible/inventory/stable
private_key:
from_secret: ansible_private_key
vault_password:
from_secret: ansible_vault_password
from_secret: ansible_vault_password

- name: deploy
- name: Update production server(s)
image: plugins/ansible:3
environment:
ANSIBLE_CONFIG: .ansible/ansible.cfg
settings:
galaxy: .ansible/roles/requirements.deploy.yaml
playbook: .ansible/deploy.yaml
inventory: .ansible/inventory/production/hosts
galaxy: .ansible/roles/requirements.update.yaml
playbook: .ansible/update.yaml
inventory: .ansible/inventory/production
private_key:
from_secret: ansible_private_key
vault_password:
from_secret: ansible_vault_password

from_secret: ansible_vault_password

trigger:
event:
- tag
- cron
cron:
- daily-updates
...

0 comments on commit 53c5a8f

Please sign in to comment.