---
- name: Install NginX
apt:
name:
- nginx-light
state: present
- name: Upload the nginx vhosts template
template:
src: "{{ item }}"
dest: /etc/nginx/sites-available/jenkins
owner: root
group: root
backup: yes
force: yes
with_first_found:
- "nginx-vhost.{{ ansible_fqdn }}.j2"
- "nginx-vhost.j2"
register: tmp
notify: reload nginx
- name: Etckeeper - commit
command: "etckeeper commit 'Ansible/nginx: maintaining Jenkins vhost'"
when: tmp.changed and etckeeper_installed
- name: Activate nginx vhost
file:
src: /etc/nginx/sites-available/jenkins
dest: /etc/nginx/sites-enabled/jenkins
state: link
command: "etckeeper commit 'Ansible/nginx: activating Jenkins vhost'"
- name: Make Jenkins only listen to loopback network interface
ini_file:
path: /etc/default/jenkins
section:
option: JENKINS_ARGS
value: '"--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --httpListenAddress=127.0.0.1"'
no_extra_spaces: yes
notify: system restart jenkins and wait
command: "etckeeper commit 'Ansible/jenkins: maintaining /etc/default/jenkins'"