1
0
Fork 0
This repository has been archived on 2023-11-22. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
ansible-jenkins-php-v1/roles/jenkins-php-v1/tasks/10_jenkins-repository.yml
2020-01-17 23:35:15 +01:00

65 lines
2 KiB
YAML

---
# Add Jenkins repository for Debian
- name: Add Jenkins-stable.io repository key
apt_key:
id: "150FDE3F7787E7D11EF4E12A9B7D32F2D50582E6"
data: "{{ lookup('file', 'jenkins-stable.io.pem') }}"
state: present
register: tmp
- name: New APT sources - commit
command: "etckeeper commit 'apt: Jenkins repository key added by Ansible'"
when: tmp.changed and etckeeper_installed
- name: Check if /etc/apt/sources.list.d/jenkins.list is managed by ansible
shell: "grep -ic '# This file is managed by Ansible' /etc/apt/sources.list.d/jenkins.list || true"
register: result
changed_when: false
- name: Config /etc/apt/sources.list.d/jenkins.list file
template:
src: "{{ item }}"
dest: /etc/apt/sources.list.d/jenkins.list
owner: root
group: root
mode: 0644
backup: no
force: "{{ result.stdout is defined and result.stdout == '1' }}" # Only manage the file if the header is present
with_first_found:
- "jenkins.list.{{ ansible_fqdn }}.j2"
- "jenkins.list.j2"
register: tmp
- name: New APT sources - commit
command: "etckeeper commit 'apt: Jenkins repository added/changed by Ansible'"
when: tmp.changed and etckeeper_installed
- name: Update APT cache
apt:
update_cache: yes
when: tmp.changed
# Install Jenkins
# (note: the Jenkins package doesn't wait for Java to be installed
# before trying to launch itself, so we install them separately)
# (note2: in case we go back downloading the .war, here is a command to
# verify it: jarsigner -verbose -certs -verify /tmp/jenkins.war
- name: Install Java
apt:
name:
- default-jdk
state: present
- name: Install Jenkins package
apt:
name:
- jenkins
state: present
register: result
- name: Loop until Jenkins is available
get_url:
url: "http://localhost:8080/login"
dest: "/dev/null"
force: True
register: tmp
until: tmp.status_code is defined and tmp.status_code == 200 or result.changed == False
retries: 10
delay: 5
changed_when: False