--- - block: - name: Jenkins package repository key apt_key: url='{{ jenkins_repo_key }}' - name: Install the jenkins stable repository apt_repository: repo='{{ jenkins_stable_repo }}' update_cache=yes when: not jenkins_use_latest - name: Install the jenkins latest repository apt_repository: repo='{{ jenkins_latest_repo }}' update_cache=yes when: jenkins_use_latest - name: Install jenkins apt: pkg={{ item }} state={{ jenkins_pkg_state }} update_cache=yes cache_valid_time=3600 with_items: '{{ jenkins_packages }}' - name: Install some jenkins requirements apt: pkg={{ item }} state={{ jenkins_pkg_state }} update_cache=yes cache_valid_time=3600 with_items: '{{ jenkins_package_requirements }}' - name: Ensure that jenkins is started and enabled service: name=jenkins state=started enabled=yes when: jenkins_install tags: jenkins - block: - name: Ensure that jenkins is stoppend and disabled service: name=jenkins state=stopped enabled=no - name: Remove the jenkins requirements apt: pkg={{ item }} state=absent with_items: '{{ jenkins_package_requirements }}' - name: Remove jenkins apt: pkg={{ item }} state=absent with_items: '{{ jenkins_packages }}' - name: Remove the jenkins stable repository apt_repository: repo='{{ jenkins_stable_repo }}' state=absent update_cache=yes - name: Remove the jenkins latest repository apt_repository: repo='{{ jenkins_latest_repo }}' state=absent update_cache=yes - name: Remove the jenkins package repository key apt_key: url='{{ jenkins_repo_key }}' state=absent when: not jenkins_install tags: jenkins