mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-09 11:20:18 +01:00
Squashed 'lemp-rhel7/roles/ansible-role-git/' content from commit b4f85aa
git-subtree-dir: lemp-rhel7/roles/ansible-role-git git-subtree-split: b4f85aa9ad5368def602809847ef0367bbb407f9
This commit is contained in:
commit
27b4fbf163
14 changed files with 365 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.LSOverride
|
84
.travis.yml
Normal file
84
.travis.yml
Normal file
|
@ -0,0 +1,84 @@
|
|||
---
|
||||
sudo: required
|
||||
|
||||
env:
|
||||
# Only test source install on latest supported OSes.
|
||||
# - distribution: centos
|
||||
# version: 7
|
||||
# init: /usr/lib/systemd/systemd
|
||||
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
# SITE: source
|
||||
# GIT_VERSION: 2.7.1
|
||||
- distribution: ubuntu
|
||||
version: 14.04
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: source
|
||||
GIT_VERSION: 2.7.1
|
||||
|
||||
# Test package install on all supported OSes.
|
||||
- distribution: centos
|
||||
version: 6
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: package
|
||||
GIT_VERSION: 1.7.1
|
||||
- distribution: centos
|
||||
version: 7
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
SITE: package
|
||||
GIT_VERSION: 1.8.3.1
|
||||
- distribution: ubuntu
|
||||
version: 14.04
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: package
|
||||
GIT_VERSION: 1.9.1
|
||||
- distribution: ubuntu
|
||||
version: 12.04
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
SITE: package
|
||||
GIT_VERSION: 1.7.9.5
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
# - sudo apt-get update
|
||||
# Pull container
|
||||
- 'sudo docker pull ${distribution}:${version}'
|
||||
# Customize container
|
||||
- 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
|
||||
|
||||
script:
|
||||
- container_id=$(mktemp)
|
||||
# Run container in detached state
|
||||
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
|
||||
|
||||
# Ansible syntax check.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml --syntax-check'
|
||||
|
||||
# Test role.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml'
|
||||
|
||||
# Test role idempotence.
|
||||
- >
|
||||
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml
|
||||
| grep -q 'changed=0.*failed=0'
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
|
||||
# Ensure Git is installed and at the right version.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm which git'
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm test -x /usr/bin/git'
|
||||
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm git --version'
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm /usr/bin/git --version | grep -qF "$GIT_VERSION"'
|
||||
|
||||
# Clean up
|
||||
- 'sudo docker stop "$(cat ${container_id})"'
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
55
README.md
Normal file
55
README.md
Normal file
|
@ -0,0 +1,55 @@
|
|||
# Ansible Role: Git
|
||||
|
||||
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-git.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-git)
|
||||
|
||||
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
|
||||
- git-svn
|
||||
|
||||
The specific Git packages that will be installed. By default, `git-svn` is included, but you can easily add this variable to your playbook's variables and remove `git-svn` if desired.
|
||||
|
||||
git_install_from_source: false
|
||||
git_install_path: "/usr"
|
||||
git_version: "2.1.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](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
|
23
defaults/main.yml
Normal file
23
defaults/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
workspace: /root
|
||||
|
||||
# If git_install_from_source is set to false, these two variables define whether
|
||||
# to use an additional repo for the package installation, and which git packages
|
||||
# will be installed.
|
||||
git_enablerepo: ""
|
||||
git_packages:
|
||||
- git
|
||||
- git-svn
|
||||
|
||||
# If set to TRUE, git will be installed from source, using the version set with
|
||||
# the 'git_version' variable instead of using a package.
|
||||
git_install_from_source: false
|
||||
git_install_path: "/usr"
|
||||
git_version: "2.7.1"
|
||||
|
||||
# If git is already installed at and older version, force a new source build.
|
||||
# Only applies if git_install_from_source is `true`.
|
||||
git_install_from_source_force_update: false
|
||||
|
||||
# Leave this at it's default.
|
||||
git_reinstall_from_source: false
|
22
meta/main.yml
Normal file
22
meta/main.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: Git version control software
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 1.9
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- development
|
||||
- system
|
62
tasks/install-from-source.yml
Normal file
62
tasks/install-from-source.yml
Normal file
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
- name: Ensure git's dependencies are installed (RedHat).
|
||||
yum: "pkg={{ item }} state=installed"
|
||||
with_items:
|
||||
- gettext-devel
|
||||
- expat-devel
|
||||
- curl-devel
|
||||
- zlib-devel
|
||||
- perl-devel
|
||||
- openssl-devel
|
||||
- subversion-perl
|
||||
- make
|
||||
- gcc
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Ensure git's dependencies are installed (Debian).
|
||||
apt: "pkg={{ item }} state=installed"
|
||||
with_items:
|
||||
- libcurl4-gnutls-dev
|
||||
- libexpat1-dev
|
||||
- gettext
|
||||
- libssl-dev
|
||||
- build-essential
|
||||
- gcc
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Get installed version
|
||||
command: git --version
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
# Ansible 1.8 feature.
|
||||
# warn: no
|
||||
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 and (git_installed_version|success 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|failed or git_reinstall_from_source
|
||||
|
||||
- name: Expand git archive.
|
||||
unarchive:
|
||||
src: "{{ workspace }}/git-{{ git_version }}.tar.gz"
|
||||
dest: "{{ workspace }}"
|
||||
creates: "{{ workspace }}/git-{{ git_version }}/README"
|
||||
copy: no
|
||||
when: git_installed_version|failed or git_reinstall_from_source
|
||||
|
||||
- name: Build git.
|
||||
command: >
|
||||
make prefix={{ git_install_path }} {{ item }}
|
||||
chdir={{ workspace }}/git-{{ git_version }}
|
||||
with_items:
|
||||
- all
|
||||
- install
|
||||
when: git_installed_version|failed or git_reinstall_from_source
|
||||
become: yes
|
23
tasks/main.yml
Normal file
23
tasks/main.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: Ensure git is installed (RedHat).
|
||||
yum:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
enablerepo: "{{ git_enablerepo }}"
|
||||
with_items: "{{ git_packages }}"
|
||||
when: (git_install_from_source == false) and (ansible_os_family == 'RedHat')
|
||||
|
||||
- name: Update apt cache (Debian).
|
||||
apt: update_cache=yes cache_valid_time=86400
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Ensure git is installed (Debian).
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
with_items: "{{ git_packages }}"
|
||||
when: (git_install_from_source == false) and (ansible_os_family == 'Debian')
|
||||
|
||||
# Install git from source when git_install_from_source is true.
|
||||
- include: install-from-source.yml
|
||||
when: git_install_from_source == true
|
15
tests/Dockerfile.centos-6
Normal file
15
tests/Dockerfile.centos-6
Normal file
|
@ -0,0 +1,15 @@
|
|||
FROM centos:6
|
||||
|
||||
# Install Ansible
|
||||
RUN yum -y update; yum clean all;
|
||||
RUN yum -y install epel-release
|
||||
RUN yum -y install git ansible sudo
|
||||
RUN yum clean all
|
||||
|
||||
# Disable requiretty
|
||||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
|
||||
CMD ["/usr/sbin/init"]
|
27
tests/Dockerfile.centos-7
Normal file
27
tests/Dockerfile.centos-7
Normal file
|
@ -0,0 +1,27 @@
|
|||
FROM centos:7
|
||||
|
||||
# Install systemd -- See https://hub.docker.com/_/centos/
|
||||
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
|
||||
RUN yum -y update; yum clean all; \
|
||||
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
|
||||
rm -f /lib/systemd/system/multi-user.target.wants/*; \
|
||||
rm -f /etc/systemd/system/*.wants/*; \
|
||||
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
||||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
||||
rm -f /lib/systemd/system/basic.target.wants/*; \
|
||||
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
||||
|
||||
# Install Ansible
|
||||
RUN yum -y install epel-release
|
||||
RUN yum -y install git ansible sudo
|
||||
RUN yum clean all
|
||||
|
||||
# Disable requiretty
|
||||
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
|
||||
|
||||
VOLUME ["/sys/fs/cgroup"]
|
||||
CMD ["/usr/sbin/init"]
|
11
tests/Dockerfile.ubuntu-12.04
Normal file
11
tests/Dockerfile.ubuntu-12.04
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM ubuntu:12.04
|
||||
RUN apt-get update
|
||||
|
||||
# Install Ansible
|
||||
RUN apt-get install -y software-properties-common python-software-properties git
|
||||
RUN apt-add-repository -y ppa:ansible/ansible
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y ansible
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
|
11
tests/Dockerfile.ubuntu-14.04
Normal file
11
tests/Dockerfile.ubuntu-14.04
Normal file
|
@ -0,0 +1,11 @@
|
|||
FROM ubuntu:14.04
|
||||
RUN apt-get update
|
||||
|
||||
# Install Ansible
|
||||
RUN apt-get install -y software-properties-common git
|
||||
RUN apt-add-repository -y ppa:ansible/ansible
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y ansible
|
||||
|
||||
# Install Ansible inventory file
|
||||
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
|
14
tests/test-package.yml
Normal file
14
tests/test-package.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
- hosts: all
|
||||
|
||||
vars:
|
||||
git_install_from_source: false
|
||||
git_install_path: /usr/local
|
||||
|
||||
pre_tasks:
|
||||
- name: Ensure build dependencies are installed (RedHat).
|
||||
yum: name=which state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
roles:
|
||||
- role_under_test
|
15
tests/test-source.yml
Normal file
15
tests/test-source.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- hosts: all
|
||||
|
||||
vars:
|
||||
git_install_from_source: true
|
||||
git_install_from_source_force_update: true
|
||||
git_version: 2.7.1
|
||||
|
||||
pre_tasks:
|
||||
- name: Ensure build dependencies are installed (RedHat).
|
||||
yum: name=which state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
roles:
|
||||
- role_under_test
|
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# This space intentionally left blank.
|
Loading…
Reference in a new issue