ansible setup added

This commit is contained in:
moleksiienko 2025-01-15 16:53:25 +02:00
parent 44cc836418
commit d3c7f6599b
10 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,11 @@
# Ansible CI/CD Setup
This Ansible playbook provisions Jenkins, Nexus for a local CI/CD pipeline.
## How to Use
1. Install Ansible: `sudo apt install ansible`.
2. Run the playbook: `ansible-playbook -i inventory/local site.yml`.
3. Verify:
- Jenkins: http://localhost:8080
- Nexus: http://localhost:8081

View file

@ -0,0 +1,5 @@
---
java_version: applejdk-17
jenkins_url: "http://localhost:8080"
ansible_become_password: <password>

View file

@ -0,0 +1,2 @@
[local]
localhost ansible_connection=local

View file

@ -0,0 +1,10 @@
---
- name: Start Jenkins agent
shell: |
curl -sO {{ jenkins_url }}/jnlpJars/agent.jar;
java -jar agent.jar -url {{ jenkins_url }} -secret {{ jenkins_agent_secret }} -name agent1 -webSocket -workDir "{{ jenkins_agent_dir }}"
args:
become: true
async: 60
poll: 0

View file

@ -0,0 +1,3 @@
---
jenkins_agent_dir: "/tmp/jenkins-agent"
jenkins_agent_secret: <jenkins-secret-token>

View file

@ -0,0 +1,13 @@
---
- name: Install Jenkins
homebrew:
name: jenkins-lts
state: present
- name: Start Jenkins Controller
shell: |
nohup /opt/homebrew/opt/openjdk@21/bin/java -Dmail.smtp.starttls.enable\=true -jar /opt/homebrew/opt/jenkins-lts/libexec/jenkins.war --httpListenAddress\=127.0.0.1 --httpPort\=8080
become: true
async: 60
poll: 0
ignore_errors: true

View file

@ -0,0 +1,2 @@
---
jenkins_dir: "/Users/moleksiienko/devopstest/jenkins"

View file

@ -0,0 +1,18 @@
---
- name: Unarchive Nexus package
unarchive:
src: "{{ nexus_dir }}/nexus.tar.gz"
dest: "/opt"
remote_src: yes
creates: "{{ nexus_dir }}/nexus-3.43.0-01"
- name: Start Nexus repository
shell: |
nohup {{ nexus_dir }}/nexus-3.43.0-01/bin/nexus run
become: true
async: 60
poll: 0
ignore_errors: true

View file

@ -0,0 +1,2 @@
---
nexus_dir: "/Users/moleksiienko/devopstest/nexus"

View file

@ -0,0 +1,7 @@
---
- hosts: local
roles:
- jenkins_master
- jenkins_agent
- nexus