--- - block: - name: Install the jenkins stable repository yum_repository: name: Jenkins description: Jenkins stable repository file: jenkins baseurl: '{{ jenkins_rh_stable_repo}}' enabled: yes gpgcheck: True gpgkey: '{{ jenkins_rh_stable_repo_key }}' state: present when: not jenkins_use_latest - name: Install the jenkins latest repository yum_repository: name: Jenkins description: Jenkins latest repository file: jenkins baseurl: '{{ jenkins_rh_latest_repo}}' enabled: yes gpgcheck: True gpgkey: '{{ jenkins_rh_latest_repo_key }}' state: present when: jenkins_use_latest - name: Install jenkins yum: pkg={{ jenkins_packages }} state={{ jenkins_pkg_state }} register: jenkins_install - name: Install jenkins additional packages yum: pkg={{ jenkins_rh_package_requirements }} state={{ jenkins_pkg_state }} - name: Set the startup jenkins options template: src=jenkins.default.j2 dest=/etc/sysconfig/jenkins owner=root group=root mode=0444 register: jenkins_must_be_restarted - name: Start and enable the Jenkins service service: name=jenkins state=started enabled=yes register: jenkins_has_been_started - name: Restart jenkins if the configuration changed service: name=jenkins state=restarted when: jenkins_must_be_restarted is changed register: jenkins_has_been_restarted when: jenkins_install tags: [ 'jenkins', 'jenkins_master', 'jenkins_pkgs' ] - block: - name: Remove jenkins yum: pkg={{ jenkins_packages }} state=absent - name: Remove the jenkins repository yum_repository: name: Jenkins file: jenkins state: absent when: not jenkins_install tags: [ 'jenkins', 'jenkins_master' ]