Ansible/roles/geerlingguy.git/tasks/install-from-source.yml

65 lines
2.1 KiB
YAML

---
- name: Include OS-specific variables (RedHat).
include_vars: "{{ ansible_os_family }}.yml"
when:
- ansible_os_family == "RedHat"
- ansible_distribution != "Fedora"
- name: Include OS-specific variables (Fedora).
include_vars: "{{ ansible_distribution }}.yml"
when: ansible_distribution == "Fedora"
- name: Include OS-specific variables (Debian).
include_vars: "{{ ansible_os_family }}.yml"
when: ansible_os_family == "Debian"
- name: Define git_install_from_source_dependencies.
set_fact:
git_install_from_source_dependencies: "{{ __git_install_from_source_dependencies | list }}"
when: git_install_from_source_dependencies is not defined
- name: Ensure git's dependencies are installed.
package:
name: "{{ git_install_from_source_dependencies }}"
state: present
- name: Get installed version.
command: >
git --version
warn=no
changed_when: false
failed_when: false
check_mode: false
register: git_installed_version
- name: Force git install if the version numbers do not match.
set_fact:
git_reinstall_from_source: true
when:
- git_install_from_source_force_update | bool
- (git_installed_version.rc == 0) and (git_installed_version.stdout | regex_replace("^.*?([0-9\.]+)$", "\\1") | version_compare(git_version, operator="!="))
- name: Download git.
get_url:
url: "https://www.kernel.org/pub/software/scm/git/git-{{ git_version }}.tar.gz"
dest: "{{ workspace }}/git-{{ git_version }}.tar.gz"
when: (git_installed_version.rc != 0) or (git_reinstall_from_source | bool)
- name: Expand git archive.
unarchive:
src: "{{ workspace }}/git-{{ git_version }}.tar.gz"
dest: "{{ workspace }}"
creates: "{{ workspace }}/git-{{ git_version }}/README"
copy: false
when: (git_installed_version.rc != 0) or (git_reinstall_from_source | bool)
- name: Build git.
command: >
make prefix={{ git_install_path }} {{ item }}
chdir={{ workspace }}/git-{{ git_version }}
with_items:
- all
- install
when: (git_installed_version.rc != 0) or (git_reinstall_from_source | bool)
become: true