ansible/roles/jenkins/tasks/main.yml

72 lines
1.5 KiB
YAML

---
- name: add jenkins repository
yum_repository:
name: jenkins
description: Jenkins stable
baseurl: https://pkg.jenkins.io/redhat-stable
gpgcheck: true
gpgkey: https://pkg.jenkins.io/redhat-stable/jenkins.io.key
- name: install packages
package:
name: "{{ item }}"
state: installed
with_items:
- jenkins
- java-1.8.0-openjdk
- name: listen only to localhost
lineinfile:
path: /etc/sysconfig/jenkins
regexp: "^JENKINS_LISTEN_ADDRESS=.*"
line: "JENKINS_LISTEN_ADDRESS=localhost"
notify: restart jenkins
- name: configure data directory
lineinfile:
path: /etc/sysconfig/jenkins
regexp: "^JENKINS_HOME=.*"
line: "JENKINS_HOME=/srv/jenkins"
notify: restart jenkins
- name: create data directory
file:
path: /export/jenkins
state: directory
mode: 0750
owner: jenkins
group: jenkins
- name: link data directory
file:
dest: /srv/jenkins
src: /export/jenkins
state: link
owner: root
group: "{{ ansible_wheel }}"
follow: false
force: true
- name: enable service
service:
name: jenkins
state: started
enabled: true
- name: allow nginx to connect jenkins
seboolean:
name: httpd_can_network_connect
state: true
persistent: true
- name: create nginx config
copy:
dest: "/etc/nginx/conf.d/{{ inventory_hostname }}/jenkins.conf"
content: |
location / {
proxy_pass http://localhost:8080/;
}
mode: 0644
owner: root
group: "{{ ansible_wheel }}"
notify: restart nginx