---
- name: Install git
  yum: name=git state=latest update_cache=yes
  tags:
    - jenkins
    - plugin

- name: Get jenkins cli
  get_url: url={{ jenkins_cli_url }} dest={{ jenkins_cli_dest }}
  register: result
  until: result.msg.find("Request failed") == -1
  retries: 5
  delay: 10
  tags:
    - jenkins
    - plugin

- name: Create updates directory
  file: path={{ jenkins_updates_dir }} mode=0755
  tags:
    - jenkins
    - plugin

- name: Create jenkins plugin file
  shell: >
    curl -L {{ jenkins_updates_center_url }} | sed '1d;$d' > {{ jenkins_updates_json_path }}
    creates={{ jenkins_updates_json_path }}
  tags:
    - jenkins
    - plugin

- name: Restart jenkins
  service: name=jenkins state=restarted
  tags:
    - jenkins
    - plugin

- name: Install git plugin
  command: java  -jar {{ jenkins_cli_dest }} -s http://{{ jenkins_host_name }}:{{ jenkins_port }} install-plugin git
  register: git_plugin_installed_result
  until: git_plugin_installed_result.stderr == ""
  retries: 5
  delay: 10
  notify: restart jenkins
  tags:
    - jenkins
    - plugin

---
- name: Install git
  yum: name=git state=latest update_cache=yes
  tags:
    - jenkins
    - plugin

- name: Get jenkins cli
  get_url: url={{ jenkins_cli_url }} dest={{ jenkins_cli_dest }}
  register: result
  until: result.msg.find("Request failed") == -1
  retries: 5
  delay: 10
  tags:
    - jenkins
    - plugin

- name: Create updates directory
  file: path={{ jenkins_updates_dir }} mode=0755
  tags:
    - jenkins
    - plugin

- name: Create jenkins plugin file
  shell: >
    curl -L {{ jenkins_updates_center_url }} | sed '1d;$d' > {{ jenkins_updates_json_path }}
    creates={{ jenkins_updates_json_path }}
  tags:
    - jenkins
    - plugin

- name: Restart jenkins
  service: name=jenkins state=restarted
  tags:
    - jenkins
    - plugin

- name: Install git plugin
  command: java  -jar {{ jenkins_cli_dest }} -s http://{{ jenkins_host_name }}:{{ jenkins_port }} install-plugin git
  register: git_plugin_installed_result
  until: git_plugin_installed_result.stderr == ""
  retries: 60
  delay: 10
  notify: restart jenkins
  tags:
    - jenkins
    - plugin

Increase the times of retry to wait until the jenkins to fully running
Increase the times of retry to wait until the jenkins to fully running
