Orchestrate Ansible playbook with Jenkins

This commit is contained in:
Kris Lamoureux 2020-04-02 20:03:40 -04:00
parent 2fc3910c3e
commit 6218c824d8
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
5 changed files with 81 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@
/*.yaml /*.yaml
!moxie.yml !moxie.yml
!upgrade-moxie.yml !upgrade-moxie.yml
!dockerbox.yml
/environments/ /environments/

18
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,18 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
dir ('environments') {
git credentialsId: 'b643c25a-d040-4692-8067-d82511509bd0',
branch: 'prom', url: 'git@github.com:krislamo/moxie-env.git'
}
ansiblePlaybook credentialsId: '4e3a5a7a-fca5-4f10-89a4-8996cf14fec7',
playbook: 'dockerbox.yml'
}
}
}
}

22
dockerbox.yml Normal file
View File

@ -0,0 +1,22 @@
# Copyright (C) 2020 Kris Lamoureux
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
- name: Install Docker Box Server
hosts: dockerbox
become: true
roles:
- ansible
- docker
- jenkins
- prometheus

View File

@ -0,0 +1 @@
deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

View File

@ -0,0 +1,39 @@
- name: Install Ansible source
template:
src: ansible.list
dest: /etc/apt/sources.list.d/ansible.list
- name: Add Ansible source key
apt_key:
keyserver: keyserver.ubuntu.com
id: 93C4A3FD7BB9C367
- name: Install Ansible
apt:
name: ansible
state: present
- name: Install Java
apt:
name: default-jre
state: present
- name: Create Jenkin's directory
file:
path: /home/{{ docker_user }}/jenkins
state: directory
recurse: yes
owner: "1000"
group: "1000"
- name: Start Jenkins Container
docker_container:
name: jenkins
image: jenkins/jenkins:2.228
state: started
restart_policy: always
ports:
- 8080:8080
- 50000:50000
volumes:
- /home/{{ docker_user }}/jenkins:/var/jenkins_home