---

# Tasks file for jenkins

- name: Load the OS specific varibles
  include_vars: "{{ role_path }}/vars/{{ ansible_os_family }}.yml"

- include: install_debian.yml
  tags:
    - install
    - jenkins
  when: ansible_os_family == "Debian"

- name : Restart jenkins if new version installed
  include : "{{ role_path }}/handlers/restart_jenkins.yml"
  when : jenkins_task_package_install.changed

- name : Waiting the application is available
  include : "{{ role_path }}/handlers/waiting_jenkins.yml"

- name : Configure jenkins launching settings
  include: configure.yml
  tags:
    - configure
    - jenkins

- name : Install and configure Jenkins CLI
  include: manage_cli.yml
  tags:
    - jenkins
    - install

- name : Manage plugins installations and upgrades
  include: plugins.yml
  tags:
    - jenkins
    - install

- name : Configure Jenkins application and its plugins
  include : "{{ role_path }}/tasks/create_config_files.yml"
  tags :
    - jenkins
    - configure

- name : Create credentials
  include : "{{ role_path }}/tasks/manage_credentials.yml"
  when : jenkins_credentials
  tags :
    - jenkins
    - configure


---

# Tasks file for jenkins

- name: Load the OS specific varibles
  include_vars: "{{ role_path }}/vars/{{ ansible_os_family }}.yml"

- include: install_debian.yml
  tags:
    - install
    - jenkins
  when: ansible_os_family == "Debian"

- name : Ensure Jenkins is started
  become  : True
  service :
    name  : "{{ jenkins_service_name }}"
    state : started

- name : Restart jenkins if new version installed
  include : "{{ role_path }}/handlers/restart_jenkins.yml"
  when : jenkins_task_package_install.changed

- name : Waiting the application is available
  include : "{{ role_path }}/handlers/waiting_jenkins.yml"

- name : Configure jenkins launching settings
  include: configure.yml
  tags:
    - configure
    - jenkins

- name : Install and configure Jenkins CLI
  include: manage_cli.yml
  tags:
    - jenkins
    - install

- name : Manage plugins installations and upgrades
  include: plugins.yml
  tags:
    - jenkins
    - install

- name : Configure Jenkins application and its plugins
  include : "{{ role_path }}/tasks/create_config_files.yml"
  tags :
    - jenkins
    - configure

- name : Create credentials
  include : "{{ role_path }}/tasks/manage_credentials.yml"
  when : jenkins_credentials
  tags :
    - jenkins
    - configure


Add task to ensure Jenkins is started after installation tasks
Add task to ensure Jenkins is started after installation tasks
