Skip to content

Instantly share code, notes, and snippets.

@petdance
Created May 8, 2024 15:51
Show Gist options
  • Save petdance/88620d4ff8bfdc677223085d24df2d7e to your computer and use it in GitHub Desktop.
Save petdance/88620d4ff8bfdc677223085d24df2d7e to your computer and use it in GitHub Desktop.
Ansible task to donwnload, build and install vim 9
---
- name: Vim 9
hosts: vim9
become: true
gather_facts: false
vars:
tarball: vim-9.1.tar.bz2
builddir: /usr/src/vim91
vimdir: /usr/local/vim91
vimexe: "{{ vimdir }}/bin/vim"
tasks:
- name: See if vim 9.1 is already installed
block:
- name: Check on vim executable
ansible.builtin.stat:
path: "{{ vimexe }}"
register: vimexe_status
- name: Skip if it is already installed
meta: end_host
when: vimexe_status.stat.exists and vimexe_status.stat.executable
- name: Compilers and ncurses
ansible.builtin.yum:
name:
- autoconf
- automake
- gcc
- gcc-c++
- make
- ncurses-devel
state: present
- name: /usr/src
ansible.builtin.file:
path: /usr/src
group: ispc
state: directory
mode: '0775'
- name: Check if tarball exists
ansible.builtin.stat:
path: "/usr/src/{{ tarball }}"
register: tarball_status
- name: Download tarball if it doesn't exist
ansible.builtin.get_url:
url: "https://www.vim.org/downloads/{{ tarball }}"
dest: /usr/src
when: not tarball_status.stat.exists
- name: Unarchive source
ansible.builtin.unarchive:
src: "/usr/src/{{ tarball }}"
dest: /usr/src
creates: "{{ builddir }}/configure"
remote_src: true
- name: Check config.h
ansible.builtin.stat:
path: "{{ builddir }}/src/auto/config.h"
register: config_h_status
- name: Configure
ansible.builtin.command:
chdir: "{{ builddir }}"
argv:
- ./configure
- "--prefix={{ vimdir }}"
- "--disable-arabic"
- "--disable-canberra"
- "--disable-darwin"
- "--disable-gpm"
- "--disable-gtktest"
- "--disable-libsodium"
- "--disable-netbeans"
- "--disable-rightleft"
- "--disable-sysmouse"
- "--disable-xsmp"
- "--disable-xsmp-interact"
- "--quiet"
when: not config_h_status.stat.exists or config_h_status.stat.size == 0
- name: Build
ansible.builtin.command:
chdir: "{{ builddir }}"
argv:
- make
- "-j10"
creates: "{{ builddir }}/src/vim"
- name: Install
ansible.builtin.command:
chdir: "{{ builddir }}"
argv:
- make
- install
creates: "{{ vimdir }}/bin/vim"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment