| --- |
| - name: Configure proxy config for Jenkins |
| template: |
| src: proxy.xml |
| dest: "{{ jenkins_home }}/proxy.xml" |
| owner: "{{ jenkins_process_user }}" |
| group: "{{ jenkins_process_group }}" |
| mode: 0664 |
| register: jenkins_proxy_config |
| when: |
| - jenkins_proxy_host | length > 0 |
| - jenkins_proxy_port | length > 0 |
| |
| - 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 |
| mode: 0644 |
| with_items: "{{ jenkins_init_changes }}" |
| register: jenkins_init_prefix |
| |
| - 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: generate groovy for initializing local admin account |
| template: |
| src: init_admin.groovy.j2 |
| dest: "{{ jenkins_home }}/init.groovy.d/basic-security.groovy" |
| owner: "{{ jenkins_process_user }}" |
| group: "{{ jenkins_process_group }}" |
| mode: 0775 |
| when: "'jenkins' not in ansible_facts.packages" |
| notify: |
| - unmask-jenkins |
| - enable-jenkins |
| - start-jenkins |