Skip to content

Instantly share code, notes, and snippets.

@PrashantBhatasana
Last active October 3, 2019 06:01
Show Gist options
  • Save PrashantBhatasana/44e2eca43c3dd33e4e7bdec46ce7a4cf to your computer and use it in GitHub Desktop.
Save PrashantBhatasana/44e2eca43c3dd33e4e7bdec46ce7a4cf to your computer and use it in GitHub Desktop.
---
- name: Demo for SampleApp-Server
hosts:
- SampleApp-Server
gather_facts: true
become: yes
become_method: sudo
tags: [jenkins]
tasks:
- name: Update the software package repository
yum:
name: "*"
update_cache: yes
- name: Install dependencies
package:
name: "{{ item }}"
state: present
with_items:
- java-1.8.0-openjdk
- git
- texlive-latex
- wget
- deltarpm
- name: Download jenkins repo
command: wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
- name: Import Jenkins CI key
rpm_key:
key: https://pkg.jenkins.io/redhat-stable/jenkins.io.key
state: present
- name: Install Jenkins
yum:
name: "jenkins"
state: present
- name: Allow port 8080
shell: iptables -I INPUT -p tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT
- name: Start the server
service:
name: jenkins
state: started
- wait_for:
port: 8080
command: cat /var/lib/jenkins/secrets/initialAdminPassword
- name: Get Admin Password
become: yes
become_method: sudo
command: cat /var/lib/jenkins/secrets/initialAdminPassword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment