diff --git a/tasks/config.yaml b/tasks/config.yaml index 67f6fcc..6b95f5d 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -21,8 +21,9 @@ with_items: - "{{ jenkins_user_home }}/plugins" -- name: Template clouds yaml file. +- name: Template jenkins service config. template: dest: "{{ jenkins_template_config_dest }}" src: "{{ jenkins_template_config_src }}" + when: ansible_os_family == 'RedHat' notify: Restart jenkins diff --git a/tasks/install.yaml b/tasks/install.yaml index 7e3274c..54de28b 100644 --- a/tasks/install.yaml +++ b/tasks/install.yaml @@ -17,5 +17,13 @@ jenkins_build_depends: "{{ __jenkins_build_depends | list }}" when: jenkins_build_depends is not defined -- include: install/redhat.yaml - when: ansible_os_family == 'RedHat' +- name: Ensure build dependencies are installed. + package: + name: "{{ item }}" + state: installed + with_items: jenkins_build_depends + +- name: Ensure jenkins is installed. + package: + name: jenkins + state: installed diff --git a/tests/files/jenkins/etc/apt/sources.list.d/jenkins.list b/tests/files/jenkins/etc/apt/sources.list.d/jenkins.list new file mode 100644 index 0000000..5d28261 --- /dev/null +++ b/tests/files/jenkins/etc/apt/sources.list.d/jenkins.list @@ -0,0 +1 @@ +deb http://pkg.jenkins-ci.org/debian binary/ diff --git a/tests/test.yaml b/tests/test.yaml index 3a99b02..c8d9673 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -18,12 +18,6 @@ rolename: "{{ lookup('pipe', 'pwd') | dirname | basename }}" pre_tasks: - # Make sure OS does not have a stale package cache. - - name: Update apt cache. - apt: - update_cache: yes - when: ansible_os_family == 'Debian' - - name: Configure yum for Jenkins repository. become: yes copy: @@ -31,6 +25,13 @@ dest: /etc/yum.repos.d when: ansible_os_family == 'RedHat' + - name: Configure apt for Jenkins repository. + become: yes + copy: + src: jenkins/etc/apt/sources.list.d/jenkins.list + dest: /etc/apt/sources.list.d + when: ansible_os_family == 'Debian' + - name: Configure gpg key for Jenkins repository. become: yes copy: @@ -44,5 +45,16 @@ key: /etc/pki/rpm-gpg/jenkins-ci.org.key when: ansible_os_family == 'RedHat' + - name: Import GPG key for Jenkins repo. + become: yes + apt_key: + data: "{{ lookup('file', 'jenkins/jenkins-ci.org.key') }}" + when: ansible_os_family == 'Debian' + + - name: Update apt cache. + apt: + update_cache: yes + when: ansible_os_family == 'Debian' + roles: - "{{ rolename }}" diff --git a/tasks/install/redhat.yaml b/vars/Debian.yaml similarity index 72% rename from tasks/install/redhat.yaml rename to vars/Debian.yaml index 7731609..f88d49c 100644 --- a/tasks/install/redhat.yaml +++ b/vars/Debian.yaml @@ -12,13 +12,5 @@ # License for the specific language governing permissions and limitations # under the License. --- -- name: Ensure build dependencies are installed. - yum: - pkg: "{{ item }}" - state: installed - with_items: jenkins_build_depends - -- name: Ensure jenkins is installed. - yum: - pkg: jenkins - state: installed +__jenkins_build_depends: + - openjdk-7-jdk