Giter VIP home page Giter VIP logo

ansible-role-git's Introduction

Ansible Role: Git

CI

Installs Git, a distributed version control system, on any RHEL/CentOS or Debian/Ubuntu Linux system.

Requirements

None.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

workspace: /root

Where certain files will be downloaded and adjusted prior to git installation, if needed.

git_enablerepo: ""

This variable, a well as git_packages, will be used to install git via a particular yum repo if git_install_from_source is false (CentOS only). Any additional repositories you have installed that you would like to use for a newer/different Git version.

git_packages:
  - git

The specific Git packages that will be installed. By default, only git is installed, but you could add additional git-related packages like git-svn if desired.

git_install_from_source: false
git_install_path: "/usr"
git_version: "2.26.0"

Whether to install Git from source; if set to true, git_version is required and will be used to install a particular version of git (see all available versions here: https://www.kernel.org/pub/software/scm/git/), and git_install_path defines where git should be installed.

git_install_from_source_force_update: false

If git is already installed at and older version, force a new source build. Only applies if git_install_from_source is true.

Dependencies

None.

Example Playbook

- hosts: servers
  roles:
    - { role: geerlingguy.git }

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

ansible-role-git's People

Contributors

dimitrisr avatar fubarhouse avatar geerlingguy avatar opdavies avatar xkerman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-git's Issues

install_from_from_source fails with darwin git

git --version says git version 2.24.2 (Apple Git-127)

the check fails, cause there's some text after the space

- (git_installed_version.rc == 0) and (git_installed_version.stdout | regex_replace("^.*?([0-9\.]+)", "\\1") is version(git_version, operator="!=")) works with the $ removed, but i'm not sure if that was there for a reason

Centos 7 install from source slightly broken

If installing from source, the ansible tasks are configured not to install the OS version of git. Instead the role will install the dependencies of git starting with gettext-devel.
The issue is that gettext-devel itself has a depedency on git, so will install git when gettext-devel is installed, so there is really no value in stopping the install of the git from OS in this case as it will be installed anyway.

This is usually not a problem at all, as Centos 7 base has an old version of git and the new version will always get downloaded and installed over it. However, when you have the ius repo enabled, git2u package is installed with the gettext-devel as a dependency as yum favours git2u over the base ok for providing git command (as it's more recent), meaning the subsequent build from source then fails typically.

Should be a simple fix to make to guarantee reliability. I'll try something and push it back at some point.

Fails on CentOs7

tried with default role as with following vars

  • role: geerlingguy.git
    git_install_from_source: false
    git_install_from_source_force_update: false

result
TASK [geerlingguy.git : Ensure git's dependencies are installed (RedHat).] *****
fatal: [default]: FAILED! => {"failed": true, "msg": "'git_install_from_source_dependencies' is undefined"}

Git did not update to latest version

I have the following on config:

---
git_install_from_source: true,
git_install_from_source_force_update: true,
git_version: "2.12.2"

The provision went well without error, but when I checked git --version on guest it still says git version 2.7.4.

I'm on:
Linux ubuntu-xenial 4.4.0-71-generic #92-Ubuntu SMP Fri Mar 24 12:59:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux.

What could I've missed?

CentOS 7: git_install_from_source alone doesn't work anymore

On CentOS 7 the dependency gettext-devel now installs git package. So even if I set git_install_from_source: true, it doesn't help as the git is already installed at the time when the check Get installed version in install-from-source.yml happens.

The workaround is:

git_install_from_source: true
git_reinstall_from_source: true

Deprecation warning?

TASK [geerlingguy.git : Get installed version] *********************************
[DEPRECATION WARNING]: always_run is deprecated. Use check_mode = no instead..

This feature will be removed in version 2.4. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.

Is this something to be concerned about?

Git installed from APT stil present after install from sources

Hi,
I've installer GIT via the "install_from_source" flag to get the last version.
Seems that the previous version from apt mirror is still present.

ctop@gh-runner-01:~$ git --version
git version 2.26.0
ctop@gh-runner-01:~$ dpkg -l |grep git
ii  findutils                          4.6.0+git+20170828-2                        amd64        utilities for finding files--find, xargs
ii  git                                1:2.17.1-1ubuntu0.6                         amd64        fast, scalable, distributed revision control system

Has a dependency on running apt-get update

Running this as the first role in a playbook, it fails initially but works if apt-get update is run. Should this be included as a step? If not, it would be helpful if the README suggested this as a dependency.

'dict object' has no attribute 'rc'

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

TASK [geerlingguy.git : Download git.] **************************************************************
task path: /path/geerlingguy.git/tasks/install-from-source.yml:42
fatal: [x]: FAILED! => {
    "msg": "The conditional check '(git_installed_version.rc != 0) or 
(git_reinstall_from_source | bool)' failed. 
The error was: error while evaluating conditional ((git_installed_version.rc != 0) or 
(git_reinstall_from_source | bool)): 'dict object' has no attribute 'rc'. 'dict object' has no
 attribute 'rc'\n\nThe error appears to be in '/path/geerlingguy.git/tasks/install-from-source.yml': 
line 42, column 3, 
but may\nbe elsewhere in the file depending on the exact syntax problem.\n\n
The offending line appears to be:\n\n\n- name: Download git.\n  ^ here\n"
}

lfs support

https://github.com/git-lfs/git-lfs/wiki/Installation#debian

Debian

Debian 7 Wheezy and similar needs to have the backports repo installed to get git >= 1.8.2
    echo 'deb http://http.debian.net/debian wheezy-backports main' > /etc/apt/sources.list.d/wheezy-backports-main.list

curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install

Gitlab hook user

I have a custom_hook in gitlab. What user runs it?
echo "$USER"
gives my an empty string.

I need access to user home dir during hook execution

Please add configuration to use https rather than git:// native git addressing (to port 9148)

This is a single line change which will allow all those working in typically restrictive corporate networks to access all git repos current inaccessible on port 9148.
This is what I adopted in my forked repo at https://github.com/danryu/ansible-role-git/blob/master/tasks/main.yml#L17

- name: configure git to use https and not native git protocol
  command: git config --global url."https://".insteadOf "git://"

and it works well in testing. Previous multi-hour hangs caused by composer trying to build drush by referencing dozens of github repos via git:// addresses are now avoided successfully.

Background provided in debugging outlined in geerlingguy/drupal-vm#101

Fix deprecation warnings for git_install_from_source

For example:

TASK [geerlingguy.git : Include OS-specific variables (RedHat).] *******************************************************
[DEPRECATION WARNING]: evaluating git_install_from_source as a bare variable, this behaviour will go away and you might
 need to add |bool to the expression in the future. Also see CONDITIONAL_BARE_VARS configuration toggle.. This feature 
will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in 
ansible.cfg.
skipping: [10.0.100.103]

This has started as of Ansible 2.8.

Install from source installs GIT 1.8.3.1

TASK [git : Ensure git's dependencies are installed (RedHat).] ***********************
Connection to 127.0.0.1 closed by remote host.anged": true, "item": "gettext-devel", "Connection to 127.0.0.1 closed."Loaded plugins: fastestmirror\nLoading mirror speeds fM302431BUG8WP:vagrant pratikkumar.chaudhar$ rect.com\n * extras: mirror.dal10.us.leaseweb.net\n * updates: distro.ibiblio.org\nResolving Dependencies\n--> Running transaction check\n---> Package gettext-devel.x86_64 0:0.19.8.1-2.el7 will be installed\n--> Processing Dependency: git for package: gettext-devel-0.19.8.1-2.el7.x86_64\n--> Running transaction check\n---> Package git.x86_64 0:1.8.3.1-12.el7_4 will be installed\n--> Processing Dependency: perl-Git = 1.8.3.1-12.el7_4 for package: git-1.8.3.1-12.el7_4.x86_64\n--> Processing Dependency: perl(Git) for package: git-1.8.3.1-12.el7_4.x86_64\n--> Running transaction check\n---> Package perl-Git.noarch 0:1.8.3.1-12.el7_4 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n

fer: git config

Ability to config git client such as user.name, user.email, gpg.program and etc

Make fails on repeated runs

Error:

TASK [geerlingguy.git : Build git.] *************************************************************************************************
failed: [myhostname] (item=all) => {"changed": true, "cmd": ["make", "prefix=/usr", "all"], "delta": "0:00:06.616542", "end": "2018-03-23 12:38:16.957448", "failed": true, "item": "all", "msg": "non-zero return code", "rc": 2, "start": "2018-03-23 12:38:10.340906", "stderr": "Writing perl.mak for Git\nmake[2]: *** [perl.mak] Error 1\nmake[1]: *** [all] Error 2\nmake: *** [all] Error 2", "stderr_lines": ["Writing perl.mak for Git", "make[2]: *** [perl.mak] Error 1", "make[1]: *** [all] Error 2", "make: *** [all] Error 2"], "stdout": "    SUBDIR git-gui\n    SUBDIR gitk-git\n    SUBDIR perl\nMakefile out-of-date with respect to /usr/lib64/perl5/Config.pm /usr/lib64/perl5/CORE/config.h\nCleaning current config before rebuilding Makefile...\nmake -f perl.mak.old clean > /dev/null 2>&1\n/usr/bin/perl Makefile.PL \"PREFIX=/usr\" \"INSTALL_BASE=\"\n==> Your Makefile has been rebuilt. <==\n==> Please rerun the make command.  <==\nfalse", "stdout_lines": ["    SUBDIR git-gui", "    SUBDIR gitk-git", "    SUBDIR perl", "Makefile out-of-date with respect to /usr/lib64/perl5/Config.pm /usr/lib64/perl5/CORE/config.h", "Cleaning current config before rebuilding Makefile...", "make -f perl.mak.old clean > /dev/null 2>&1", "/usr/bin/perl Makefile.PL \"PREFIX=/usr\" \"INSTALL_BASE=\"", "==> Your Makefile has been rebuilt. <==", "==> Please rerun the make command.  <==", "false"]}
changed: [myhostname] => (item=install)

First idea that comes to mind is something like "Retry this task if the standard output of it contains 'Please rerun the make command.'" :D

Deprecation warning in Ansible 2.7

TASK [geerlingguy.git : Ensure git is installed (Debian).] *************************************************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of using a
 loop to supply multiple items and specifying `name: {{ item }}`, please use `name: u'{{ git_packages }}'` and remove 
the loop. This feature will be removed in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
ok: [server] => (item=[u'git', u'git-svn'])

Tag for version 1.2.2 is missing

version 1.2.2 missing from tags

I use tags to lock in stability with my integration. Why was the tag removed? Whats the best way to implement and insure that it does not break my build because a version is no longer there?

task: [geerlingguy.git | Build git.] is always skipping

Hi,

On a fresh CentOS 7.1, with no git installed, I'm trying to install git with this config

git_install_from_source: true
git_version: 2.6.4

But the task "[geerlingguy.git | Build git.]" is always skipping. In the task "Ensure git's dependencies are installed (RedHat)." it seems that the depencency "gettext-devel" is depending on git itself, thus installing the regular git 1.8.4 version from the regular repo. Maybe this causes the issue?

==> davy.dev: TASK: [geerlingguy.git | debug msg="git_install_from_source {{ git_install_from_source }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_install_from_source True"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Ensure git is installed (RedHat).] *******************
==> davy.dev: skipping: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Update apt cache (Debian).] **************************
==> davy.dev: skipping: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Ensure git is installed (Debian).] *******************
==> davy.dev: skipping: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_version {{ git_version }}"] ***********
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_version 2.6.4"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Check if git is installed.] **************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_installed 1 {{ git_installed|failed }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_installed 1 True"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Ensure git's dependencies are installed (RedHat).] ***
==> davy.dev: changed: [localhost] => (item=gettext-devel,expat-devel,curl-devel,zlib-devel,perl-devel,openssl-devel,subversion-perl,gcc)
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Check if git is installed.] **************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_installed 2 {{ git_installed|failed }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_installed 2 False"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Ensure git's dependencies are installed (Debian).] ***
==> davy.dev: skipping: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Check if git is installed.] **************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_installed 3 {{ git_installed|failed }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_installed 3 False"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Download git.] ***************************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Check if git is installed.] **************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_installed 4 {{ git_installed|failed }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_installed 4 False"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Expand git archive.] *********************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Check if git is installed.] **************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_installed 5 {{ git_installed|failed }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_installed 5 False"
==> davy.dev: }
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Build git.] ******************************************
==> davy.dev: skipping: [localhost] => (item=all)
==> davy.dev: skipping: [localhost] => (item=install)
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | Check if git is installed.] **************************
==> davy.dev: ok: [localhost]
==> davy.dev:
==> davy.dev: TASK: [geerlingguy.git | debug msg="git_installed 6 {{ git_installed|failed }}"] ***
==> davy.dev: ok: [localhost] => {
==> davy.dev:     "msg": "git_installed 6 False"
==> davy.dev: }
==> davy.dev:

Make dependencies configurable.

Sup Jeff!

For the purposes of adding this role into my own playbooks for testing on unsupported architectures such as Ubuntu 12.10, 13.04, 14.10, 15.10, would you consider making the dependency lists optionally configurable so that when defined the role won't cause an error when a particular package cannot be found by the package manager?

My interim solution is to basically remove your role in these edge cases in favour of something else - what that is exactly is yet to be determined - or I could fork this one and do that myself despite not wanting to.

Kind regards,
Karl

install_from_source causes repeated builds when prefix is not the default

Hi, I'm using your playbook with the following vars:

git_version: 2.26.2
git_install_from_source: true
git_install_from_source_force_update: true
git_install_path: "/opt"

It looks as if the custom install prefix is causing the version check to fail on repeated runs.

I can probably submit a patch over the weekend if you like?

The conditional check 'ansible_os_family == 'RedHat'' failed

I tried to install it on a Vagrant Machine with Debian 10 and got this error:

PLAY [serv04] ******************************************************************

TASK [geerlingguy.git : Ensure git is installed (RedHat).] *********************
fatal: [serv04]: FAILED! => {"msg": "The conditional check 'ansible_os_family == 'RedHat'' failed. The error was: error while evaluating conditional (ansible_os_family == 'RedHat'): 'ansible_os_family' is undefined\n\nThe error appears to be in '/home/user/myproject/ansible/playbooks/provision/roles/geerlingguy.git/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Ensure git is installed (RedHat).\n  ^ here\n"}

PLAY RECAP *********************************************************************
serv04                     : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

No package matching 'git-svn' found available, installed or updated

I get an error when using this role on RHEL 7.4

TASK [geerlingguy.git : Ensure git is installed (RedHat).] *********************
fatal: [ansible]: FAILED! => {"changed": false, "msg": "No package matching 'git-svn' found available, installed or updated", "rc": 126, "results": ["No package matching 'git-svn' found available, installed or updated"]}

Source install fails on Ubuntu 16.04 on 'Force git install' task

See failed build: https://travis-ci.org/geerlingguy/ansible-role-git/jobs/338217371

TASK [role_under_test : Force git install if the version numbers do not match] ***
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'git_installed_version|success and (git_installed_version.stdout | regex_replace(\"^.*?([0-9\\.]+)$\", \"\\\\1\") | version_compare(git_version, operator=\"!=\"))' failed. The error was: error while evaluating conditional (git_installed_version|success and (git_installed_version.stdout | regex_replace(\"^.*?([0-9\\.]+)$\", \"\\\\1\") | version_compare(git_version, operator=\"!=\"))): 'dict object' has no attribute 'stdout'\n\nThe error appears to have been in '/etc/ansible/roles/role_under_test/tasks/install-from-source.yml': line 41, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Force git install if the version numbers do not match\n  ^ here\n"}

Fedora24 support?

Just running a test via your Ansible role on your Docker image for Fedora24 and this came up.

I'm under the assumption this is a relatively easy fix, and it is outside of the scope of support for this role - so I'm not exactly sure how you feel about it.

"msg": "Failed to find handler for \"/root/git-2.9.3.tar.gz\". Make sure the required command to extract the file is installed. Commands \"gtar\" and \"tar\" not found. Command \"unzip\" not found."

Install fails oh RHEL7

Fails with the following output:

577
TASK [geerlingguy.git : Ensure git's dependencies are installed (RedHat).] *****10:40:22
578
�ok: [] => (item=gettext-devel)�
579
�ok: [] => (item=expat-devel)�
580
�ok: [] => (item=curl-devel)�
581
�ok: [] => (item=zlib-devel)�
582
�changed: [] => (item=perl-devel)�
583
�ok: [] => (item=openssl-devel)�
584
�failed: [] (item=subversion-perl) => {"changed": false, "failed": true, "item": "subversion-perl", "msg": "No package matching 'subversion-perl' found available, installed or updated", "rc": 126, "results": ["No package matching 'subversion-perl' found available, installed or updated"]}�
585
�ok: [] => (item=make)�
586
�ok: [] => (item=gcc)�```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.