Introduction
How to install Git using Ansible – 2018 version
Install Git 2.16.1 using Ansible.
(Applicable to this article)
– Those who are interested in Ansible
(Content of verification)
– Install Git using Ansible.
(Ansible execution environment)
– Virtualization software: Oracle VM VirtualBox 5.2.6
– OS: Fedora 27
– Ansible: 2.5.0
– Internet connection: possible
1. Preparing for installation
1.1. Create a role.
# cat roles/git_install/tasks/main.yml --- - name: Install yum package yum: name: "{{ item }}" with_items: - curl-devel - expat-devel - gettext-devel - openssl-devel - zlib-devel - wget - gcc - cpan - name: Get git binary unarchive: src: "{{ git_url }}" dest: "{{ git_temp_dir }}" remote_src: yes changed_when: false - name: Make all git binary make: chdir: "{{ git_binary_dir }}" target: all params: prefix: "{{ git_prefix }}" changed_when: false - name: Make install git binary make: chdir: "{{ git_binary_dir }}" target: install params: prefix: "{{ git_prefix }}" changed_when: false - name: Remove file file: path: "{{ git_binary_dir }}" state: absent changed_when: false
# cat roles/git_install/vars/main.yml git_version: 2.16.1 git_prefix: /usr/local git_temp_dir: /tmp git_binary_dir: "{{ git_temp_dir }}/git-{{ git_version }}" git_url: "https://www.kernel.org/pub/software/scm/git/git-{{ git_version }}.tar.gz"
1.2. Create site.yml.
# cat site.yml --- - name: Install git hosts: all gather_facts: false become: true roles: - git_install
2. Perform installation
2.1. Execute ansible-playbook.
# ansible-playbook -i inventory/local/hosts site.yml PLAY [Install git] *********************************************************************************************************** TASK [git_install : Install yum package] ************************************************************************************* changed: [test] => (item=[u'curl-devel', u'expat-devel', u'gettext-devel', u'openssl-devel', u'zlib-devel', u'wget', u'gcc', u'cpan']) TASK [git_install : Get git binary] ****************************************************************************************** ok: [test] TASK [git_install : Make all git binary] ************************************************************************************* ok: [test] TASK [git_install : Make install git binary] ********************************************************************************* ok: [test] TASK [git_install : Remove file] ********************************************************************************************* ok: [test] PLAY RECAP ******************************************************************************************************************* test : ok=5 changed=1 unreachable=0 failed=0
2.2. Make sure that Git is installed.
# git --version git version 2.16.1
Summary
Refactoring is not executed.
Therefore, I think that you can carry out refactoring as necessary.
I hope that you can contribute to the development of Ansible.
コメントを残す