--- - 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 when: jenkins_install tags: [ 'jenkins', 'jenkins_master' ] - block: - name: Ensure that jenkins is stoppend and disabled service: name=jenkins state=stopped enabled=no - 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' ]