ansible scripts

This commit is contained in:
Oleg Mykolaishyn 2021-03-26 13:50:47 +02:00
parent c10b03eef1
commit ca95a17c46
4 changed files with 166 additions and 0 deletions

47
ansible/agent-1.yml Normal file
View file

@ -0,0 +1,47 @@
---
- name: Docker push
hosts: agent-1
become: yes
tasks:
- name: Install python3
apt:
name: python3-pip
state: present
- name: docker-py
pip:
name: docker-py
state: absent
- name: install docker pip
pip:
name: docker
state: present
- name: Install docker
apt:
name: docker.io
state: present
update_cache: yes
- name: Setting mode for docker.sock
shell: sudo chmod 666 /var/run/docker.sock
- name: Docker service started
service:
name: docker
state: started
- name: Docker prune
docker_container:
name: spring-petclinic
state: absent
- name: Start the container
docker_container:
name: spring-petclinic
image: "owlleg68/spring-petclinic:latest"
state: started
published_ports:
- 0.0.0.0:8082:8080

39
ansible/builder.yml Normal file
View file

@ -0,0 +1,39 @@
---
- name: Setup builder instance
hosts: builder
become: yes
tasks:
#=========Git===========
- name: Install Git
apt:
name: git
state: present
update_cache: yes
#============Java======
- name: Install Java-8
apt:
name: openjdk-8-jdk
state: present
#============Maven========
- name: Install Maven
apt:
name: maven
state: present
#=========Docker==========
- name: Install docker
apt:
name: docker.io
state: present
update_cache: yes
- name: Setting mode for docker.sock
shell: sudo chmod 666 /var/run/docker.sock
~
~

54
ansible/dev-tools.yml Normal file
View file

@ -0,0 +1,54 @@
---
- name: Setup dev-tools instance
hosts: dev-tools
become: yes
tasks:
#=========Git===========
- name: Install Git
apt:
name: git
state: present
update_cache: yes
#============Java======
- name: Install Java-8
apt:
name: openjdk-8-jdk
state: present
#============Maven========
- name: Install Maven
apt:
name: maven
state: present
#=======Jenkins=======
- name: Wget url
shell: wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
- name: Adding to list
shell: sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
- name: Install Jenkins
apt:
name: jenkins
state: present
update_cache: yes
- name: Start jenkins
service:
name: jenkins
state: started
- name: init password jenkin
shell: sudo cat /var/lib/jenkins/secrets/initialAdminPassword
changed_when: false
register: result
- name: print init password jenkins
debug:
var: result.stdout

26
ansible/hosts Normal file
View file

@ -0,0 +1,26 @@
#===============================
[dev-tools]
35.198.158.96
[dev-tools:vars]
ansible_user=owlleg6
ansible_ssh_private_key_file=/home/owlleg6/.ssh/ansible-key.pem
#===========================
[builder]
34.89.200.191
[builder:vars]
ansible_user=owlleg6
ansible_ssh_private_key_file=/home/owlleg6/.ssh/ansible-key.pem
#==============
[agent-1]
35.223.139.130
[agent-1:vars]
ansible_user=owlleg6
ansible_ssh_private_key_file=/home/owlleg6/.ssh/ansible-key.pem