DevOps Series Using Ansible to Build GNU Guile

0
4542

This is the 22nd article in the DevOps series and here we will use Ansible to automate the process of building GNU Guile from its source code. GNU ‘Guile’ is an acronym for GNU Ubiquitous Intelligent Language for Extensions, which is an implementation of the Scheme programming language and an extension language for the GNU Project.

GNU Guile was designed by Aubrey Jaffer, Tom Lord and Miles Bader and was first made available in 1993. You can write desktop, Web and command line applications in GNU Guile. The latest stable version, as of July 2018, is v 2.2.4. It is released under the GPL and is available for both IA-32 and x86-64 platforms.

Setup

A Parabola GNU/Linux-libre (x86_64) 2018.06.02 ISO is used to set up a guest virtual machine (VM) using KVM/QEMU. The host system is also a Parabola GNU/Linux-libre x86_64 system and Ansible is installed using the distribution package manager. The version of Ansible used is 2.6.0 as indicated below:

$ ansible --version

ansible 2.6.0

config file = /etc/ansible/ansible.cfg

configured module search path = [‘/home/guest/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]

ansible python module location = /usr/lib/python3.6/site-packages/ansible

executable location = /usr/bin/ansible

python version = 3.6.5 (default, May 11 2018, 04:00:52) [GCC 8.1.0]

The Ansible inventory and playbook files are created on the host system, as follows:

ansible/inventory/kvm/

/playbooks/configuration/

The inventory/kvm/inventory file contains the following:

guile ansible_host=192.168.122.109 ansible_connection=ssh ansible_user=parabola ansible_password=password

The ‘sudo’ package needs to be installed in the guest Parabola VM. A Parabola user is created in the guest VM and sudo access is provided for this user using the ‘visudo’ command. Python and Openssh software are also required to be installed on the guest VM. The ssh daemon is started in the guest VM using the following command:

$ sudo systemctl start sshd.service

You should add an entry in the /etc/hosts file on the host system for the Parabola guest VM, as indicated below:

192.168.122.109 guile

You can now test the connectivity from Ansible to the Parabola guest VM using the following Ansible command:

$ ansible -i inventory/kvm/inventory guile -m ping

guile | SUCCESS => {

“changed”: false,

“ping”: “pong”

}

Software dependencies

GNU Guile requires a number of software dependencies, such as gmp, libunistring, libffi and readline. The essential build tools—autoconf, automake, libtool, flex, gcc, gc and make — are also needed for building GNU Guile. The Ansible playbook to install the above software is given below:

---

- name: Repository setup

hosts: guile

become: yes

become_method: sudo

gather_facts: yes

tags: [packages]

tasks:

- name: Install dependencies

package:

name: “{{ item }}”

state: latest

with_items:

- “git”

- “gmp”

- “libunistring”

- “libffi”

- “readline”

- “autoconf”

- “libtool”

- “automake”

- “flex”

- “pkgconf”

- “gcc”

- “gc”

- “make”

The above playbook can be invoked using the following command:

$ ansible-playbook -i inventory/kvm/inventory playbooks/configuration/guile.yml --tags packages -vv -K

The -vv represents the verbosity in the Ansible output. You can use up to four ‘v’ s for a more detailed output. The -K option prompts for the sudo password for the guest Parabola user account.

GNU Guile

The master branch from the GNU Guile Git repository (git.sv.gnu.org/guile.git) will be used as the source for the build process. The source code is cloned to the /home/parabola/guile directory. The basic GNU Autotools procedure of running autogen.sh, configure and make in the source code will compile GNU Guile. The build will take a few hours to complete, even on the latest hardware. The Ansible playbook to compile GNU Guile is as follows:

- name: Build guile

hosts: guile

tags: [guile]

vars:

guile_home: “/home/parabola/guile”

tasks:

- name: Clone Guile from git

git:

repo: ‘git://git.sv.gnu.org/guile.git’

dest: “{{ guile_home }}”

- name: Run autogen.sh

command: ./autogen.sh

args:

chdir: “{{ guile_home }}”

- name: Run configure

command: ./configure

args:

chdir: “{{ guile_home }}”

- name: Run make

command: make

args:

chdir: “{{ guile_home }}”

The above playbook can be invoked using the following command:

$ ansible-playbook -i inventory/kvm/inventory playbooks/configuration/guile.yml --tags guile -vv -K

Installation

The built executables, libraries and header files can be installed on the guest VM. By default, the make install command will install the artifacts to /usr/local. The Ansible playbook for installation is given below for reference:

- name: Install guile

hosts: guile

become: yes

become_method: sudo

tags: [install]

vars:

guile_home: “/home/parabola/guile”

tasks:

- name: Install Guile

command: make install

args:

chdir: “{{ guile_home }}”

The above playbook can be invoked using the following command:

$ ansible-playbook -i inventory/kvm/inventory playbooks/configuration/guile.yml --tags install -vv -K

Tests

The GNU Guile source code comes with a comprehensive test suite that you can invoke using make check to run tests against the built binary. The following Ansible playbook will run the GNU Guile tests:

- name: Test guile

hosts: guile

tags: [test]

vars:

guile_home: “/home/parabola/guile”

tasks:

- name: Run Guile tests

command: make check

args:

chdir: “{{ guile_home }}”

The above playbook can be invoked using the following command:

$ ansible-playbook -i inventory/kvm/inventory playbooks/configuration/guile.yml --tags test -vv -K

Documentation

TeX is required to generate PDFs from the built-in documentation sources in the GNU Guile code repository. The following Ansible playbook will generate the PDF documentation:

- name: Generate documentation

hosts: guile

become: yes

become_method: sudo

gather_facts: yes

tags: [docs]

vars:

guile_home: “/home/parabola/guile”

tasks:

- name: Install texlive-core

package:

name: texlive-core

state: latest

- name: Generate documentation

command: make pdf

args:

chdir: “{{ guile_home }}”

A sample execution output of invoking the above playbook is given below:

$ ansible-playbook -i inventory/kvm/inventory playbooks/configuration/guile.yml --tags docs -K

SUDO password:

PLAY [Repository setup] *************************************

TASK [Gathering Facts] **************************************

ok: [guile]

PLAY [Build guile] ******************************************

TASK [Gathering Facts] **************************************

ok: [guile]

PLAY [Install guile] ****************************************

TASK [Gathering Facts] **************************************

ok: [guile]

PLAY [Test guile] *******************************************

TASK [Gathering Facts] **************************************

ok: [guile]

PLAY [Generate documentation] *******************************

TASK [Gathering Facts] **************************************

ok: [guile]

TASK [Install texlive-core] *********************************

changed: [guile]

TASK [Generate documentation] *******************************

changed: [guile]

PLAY [Run benchmarks] ***************************************

TASK [Gathering Facts] **************************************

ok: [guile]

PLAY RECAP **************************************************

guile : ok=8 changed=2 unreachable=0 failed=0

The following PDFs are built and available in the GNU Guile sources directory:

$ find . -name *.pdf

./doc/ref/scheme.pdf

./doc/ref/gds.pdf

./doc/ref/guile.pdf

./doc/ref/hierarchy.pdf

./doc/r5rs/r5rs.pdf

Benchmarking

A benchmark-guile script is available to run benchmarks against the built binaries. The following Ansible playbook can be used to run benchmarking:

- name: Run benchmarks

hosts: guile

gather_facts: yes

tags: [benchmarks]

vars:

guile_home: “/home/parabola/guile”

tasks:

- name: Run benchmarks

command: ./benchmark-guile

args:

chdir: “{{ guile_home }}”

The above playbook can be invoked using the following command:

$ ansible-playbook -i inventory/kvm/inventory playbooks/configuration/guile.yml --tags benchmarks -vv -K

You can learn more about GNU Guile from its home page at https://www.gnu.org/software/guile/.

LEAVE A REPLY

Please enter your comment!
Please enter your name here