Ansible/roles/geerlingguy.jenkins/tasks/settings.yml
James Tombleson 642da849d6 Added Roles
Jenkins
Java
Adding Elastic support for clusters
2019-04-29 16:08:04 -07:00

70 lines
2.0 KiB
YAML

---
- name: Check if jenkins_init_file exists.
stat:
path: "{{ jenkins_init_file }}"
register: jenkins_init_file_stat
- name: Ensure jenkins_init_file exists.
file:
path: "{{ jenkins_init_file }}"
state: touch
when: not jenkins_init_file_stat.stat.exists
- name: Modify variables in init file.
lineinfile:
dest: "{{ jenkins_init_file }}"
insertafter: '^{{ item.option }}='
regexp: '^{{ item.option }}=\"\${{ item.option }} '
line: '{{ item.option }}="${{ item.option }} {{ item.value }}"'
state: present
with_items: "{{ jenkins_init_changes }}"
register: jenkins_init_prefix
- name: Set the Jenkins home directory.
lineinfile:
dest: "{{ jenkins_init_file }}"
regexp: '^JENKINS_HOME=.*'
line: 'JENKINS_HOME={{ jenkins_home }}'
register: jenkins_home_config
- name: Immediately restart Jenkins on init config changes.
service: name=jenkins state=restarted
when: jenkins_init_prefix.changed
tags: ['skip_ansible_lint']
- name: Set HTTP port in Jenkins config.
lineinfile:
backrefs: true
dest: "{{ jenkins_init_file }}"
regexp: '^{{ jenkins_http_port_param }}='
line: '{{ jenkins_http_port_param }}={{ jenkins_http_port }}'
register: jenkins_http_config
- name: Ensure jenkins_home {{ jenkins_home }} exists
file:
path: "{{ jenkins_home }}"
state: directory
owner: jenkins
group: jenkins
mode: u+rwx
follow: true
- name: Create custom init scripts directory.
file:
path: "{{ jenkins_home }}/init.groovy.d"
state: directory
owner: "{{ jenkins_process_user }}"
group: "{{ jenkins_process_group }}"
mode: 0775
- name: Trigger handlers immediately in case Jenkins was installed
meta: flush_handlers
- name: Immediately restart Jenkins on http or user changes.
service: name=jenkins state=restarted
when: >
(jenkins_users_config is defined and jenkins_users_config.changed)
or (jenkins_http_config is defined and jenkins_http_config.changed)
or (jenkins_home_config is defined and jenkins_home_config.changed)
tags: ['skip_ansible_lint']