Ansible in a Continuous Build System

The Eclipse OpenJ9 Jenkins server runs many jobs everyday, including compile and test jobs. The majority of these jobs can only run properly if the machine they run on has all the proper dependencies installed. When dependencies are modified the updates have to be installed on many machines, which normally would be time consuming and leave room for human error.

Ansible playbooks are useful in this situation because the change to the dependency only needs to be made once in the playbook, instead of on every machine. Additionally, if Ansible Tower, or the open source version AWX is used, the playbook can be applied to all target machines at the same time. Ansible playbooks can also specify what architecture/OS combination a specific step is supposed to run on, allowing for more steps per playbook and fewer playbooks overall.

Eclipse OpenJ9 contributes to and uses Ansible playbooks hosted by AdoptOpenJDK because they are more efficient than manually updating/installing dependencies. Adopt has separate playbooks based on major operating system types, such as Unix systems and Windows systems. Each playbook is then divided up into various roles, where each role is used to setup a specific dependency. This is so the person running the playbook can choose which roles are run, and which dependencies are installed. The following is an example of an Ansible playbook directory structure (retrieved from https://github.com/AdoptOpenJDK/openjdk-infrastructure/tree/master/ansible/playbooks/AdoptOpenJDK_Unix_Playbook).

.
├── group_vars
│   └── all
│       └── adoptopenjdk_variables.yml
├── main.yml
├── README.md
└── roles
    ├── Ant-Contrib
    │   └── tasks
    │       └── main.yml
    ├── ccache
    │   └── tasks
    │       └── main.yml
    ├── Clean_Up
    │   └── tasks
    │       └── main.yml
    ├── cmake
    │   └── tasks
    │       └── main.yml
    ├── Common
    │   ├── tasks
    │   │   ├── build_packages_and_tools.yml
    │   │   ├── CentOS.yml
    │   │   ├── FreeBSD.yml
    │   │   ├── main.yml
    │   │   ├── OracleLinux.yml
    │   │   ├── RedHat.yml
    │   │   ├── SLES.yml
    │   │   └── Ubuntu.yml
    │   └── vars
    │       ├── CentOS.yml
    │       ├── FreeBSD.yml
    │       ├── OracleLinux.yml
    │       ├── RedHat.yml
    │       ├── SLES.yml
    │       └── Ubuntu.yml
    ├── CPAN
    │   └── tasks
    │       └── main.yml
    ├── Crontab
    │   └── tasks
    │       └── main.yml
    ├── Debug
    │   └── tasks
    │       └── main.yml
    ├── Docker
    │   └── tasks
    │       └── main.yml
    ├── gcc_48
    │   └── tasks
    │       └── main.yml
    ├── GIT_Source
    │   └── tasks
    │       └── main.yml
    ├── Jenkins_User
    │   └── tasks
    │       └── main.yml
    ├── Nagios_Master_Config
    │   └── tasks
    │       └── main.yml
    ├── Nagios_Plugins
    │   └── tasks
    │       ├── additional_plugins
    │       │   ├── check_pkg
    │       │   ├── check_sw_up
    │       │   ├── check_yum
    │       │   └── check_zypper
    │       ├── main.yml
    │       ├── nagios_CentOS.yml
    │       ├── nagios_FreeBSD.yml
    │       ├── nagios_RedHat.yml
    │       ├── nagios_SLES.yml
    │       └── nagios_Ubuntu.yml
    ├── NTP_TIME
    │   └── tasks
    │       └── main.yml
    ├── NVidia_Cuda_Toolkit
    │   └── tasks
    │       └── main.yml
    ├── Security
    │   └── tasks
    │       └── main.yml
    ├── Superuser
    │   └── tasks
    │       └── main.yml
    ├── Swap_File
    │   └── tasks
    │       └── main.yml
    ├── Vendor
    │   └── tasks
    │       └── main.yml
    └── x11
        └── tasks
            └── main.yml

47 directories, 46 files

As an example of the efficiency of Ansible playbooks, I made changes to the Unix playbook to recompile Protobuf with different configure options in this AdoptOpenJDK/openjdk-infrastructure PR #883, and needed to apply these changes to over 10 machines. With a simple change to the playbook and the use of AWX, I was able to implement the changes very quickly and easily.

To summarize, ansible playbooks are beneficial because they are more efficient than manual installation, and cut down on human error.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s