Skip to main content

YML_Scripts

YML Scripts

build_jenkins

---

- name: Network Getting Started First Playbook Extended
gather_facts: false
hosts: jenkins
become: yes
become_user: root
tasks:

- name: Upgrade all packages
yum:
name: '*'
state: latest

- rpm_key:
state: present
key: https://jenkins-ci.org/redhat/jenkins-ci.org.key

- name: Download Jenkins Repo
get_url:
url: http://pkg.jenkins-ci.org/redhat/jenkins.repo
dest: /etc/yum.repos.d/jenkins.repo
mode: '0644'

- name: yum-clean-metadata
command: yum clean metadata
args:
warn: no

- name: Create java vars
copy:
dest: "/etc/profile.d/java.sh"
content: |
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))
export PATH=$PATH:$JAVA_HOME/bin
export JRE_HOME=/usr/lib/jvm/jre
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar

- name: Install Java 11 and Jenkins
yum:
name: "{{packages}}"
state: latest
vars:
packages:
- java-11-openjdk-devel
- jenkins
become: yes
become_user: root

shutdown_all

---
- name: shutdown
become: 'yes'
become_method: sudo
hosts: jenkins

tasks:
- name: shutdown hosts
command: /sbin/shutdown -h now
when: ansible_facts['os_family'] == "RedHat"
ignore_errors: 'yes'
...

start_jenkins

---

- name: Network Getting Started First Playbook Extended
gather_facts: false
hosts: jenkins
become: yes
become_user: root
tasks:

- name: Start Jenkins
systemd:
name: jenkins
state: started

- firewalld:
port: 8080/tcp
zone: public
permanent: yes
immediate: yes
state: enabled

stop_jenkins

---

- name: Network Getting Started First Playbook Extended
gather_facts: false
hosts: jenkins
become: yes
become_user: root
tasks:

- name: Start Jenkins
systemd:
name: jenkins
state: stopped

- firewalld:
port: 8080/tcp
zone: public
permanent: yes
immediate: yes
state: disabled

update_yum

---

- name: Upgrade and add required base packages
gather_facts: false
hosts: base
tasks:

- name: upgrade all packages
yum:
name: '*'
state: latest
become: yes
become_user: root

- name: install
yum:
name: "{{packages}}"
state: latest
vars:
packages:
- bind-utils
- telnet
- wget
become: yes
become_user: root