Skip to content

This role installs and manages the SCL Software Collections repository, packages/collections for Fedora, CentOS, and Scientific Linux

License

Notifications You must be signed in to change notification settings

smbambling/ansible-role-scl

Repository files navigation

SCL (Software Collections Linux)

Ansible Galaxy Build Status CodeClimate IssueCount

Table of Contents

  1. Overview
  2. Requirements
  3. Role Variables
  4. Dependencies
  5. Examples
  6. Development / Contributing
  7. License
  8. Author Information

Overview

This role installs and manages the SCL Software Collections repository, packages/collections for Fedora, CentOS, and Scientific Linux. Additionally it can create wrapper wrapper scripts to make calling the SCL collections binaries

Requirements

This role has been tested with Ansible 2.9 or higher and platform requirements are listed in the metadata file.

Compatibility

This role has been tested against the following distributions and Ansible version:

- Distribution Ansible 2.9
- Centos 6 yes
- Centos 7 yes

If you are looking for a version compatible with an older Ansible release please see the legacy branch

Role Variables

The variables that can be passed to this role and a brief description about them are as follows. (For all variables, take a look at defaults/main.yml)

# Toggle to enable creation/management
# of the SCL YUM repositories
scl_manage_repo: yes

# The Base URL location of the SCL sclo repository
scl_repo_sclo_sclo_baseurl:
  "http://mirror.centos.org/centos/{{ ansible_distribution_major_version }}/sclo/$basearch/sclo/"

# The Base URL location of the SCL rh repository
scl_repo_sclo_rh_baseurl:
  "http://mirror.centos.org/centos/{{ ansible_distribution_major_version }}/sclo/$basearch/rh"
  
# Array of wrapper scripts to create for SCL installed binaries
scl_wrappers:
  - {collection: 'rh-ruby23', command: 'ruby'}
  - {collection: 'rh-python35', command: 'python'}

# Array of Collections/Packages to install via SCL
scl_packages:
  - {name: 'rh-ruby23', state: 'latest'}
  - {name: 'rh-python35', state: 'latest'}

# Array (of hashes) of Ruby Gems to manage
scl_ruby_gems:
  - {
    ruby_ver: 'rh-ruby23',
    name: 'fast_github',
    state: 'present',
    }

# Array (of hashes) of Python PIPs to manage
scl_python_pips:
  - {
    python_ver: 'rh-python35',
    name: 'snakeoil',
    state: 'present',
    }

Dependencies

None

Example Playbook(s)

  1. Management of the SCL YUM repositories
Disable repository management
roles:
  - role: ansible-role-scl
    scl_manage_repo: false
Modify YUM repository base URLs
roles:
  - role: ansible-role-scl
    scl_repo_sclo_sclo_baseurl:
      "http://mylocalmirror.local/centos/6/sclo/$basearch/sclo/"
  1. Install wrapper scripts for SCL installed binaries

    The variable scl_wrappers generates wrapper/shebang scripts in /usr/local/bin:

    Each entry requires a hash with:

    • collection(required)
    • command(optional)

    If the command key is omited an scl wrapper script will be created

    scl-wrappper-[collection name] that can be used to call any command with with the collection sourced via SCL. For example listing all the PIPs installed under SCL rh-python35

    scl-wrapper-rh-python35 pip list

    If the command key is set an scl shebang script will be created that points to the command/binary specified.

    scl-shebang-[collection name] that can be used for inclusion in scripts. For example put the following in the wrapper line of a script written in ruby 2.2

    #!/usr/local/bin/scl-shebang-rh-ruby22

    The script will properly source all necessary environment variables for the desired ruby environment without having to declare scl enable rh-ruby22 -- ruby my_script.rb each time my_script.rb is run

    roles:
     - role: ansible-role-scl
       scl_wrappers:
         - {collection: 'rh-ruby22', command: 'ruby'}
         - {collection: 'rh-python35', command: 'python'}
  2. Install SCL collections/packages via yum module

    Pre-compiled Gems/PIPs packages (RPMs) can be installed via the scl_packages variable.

    Each entry requires a hash with:

    • name(required)
    • state(optional)[defaults: present]
    roles:
     - role: ansible-role-scl
       scl_packages:
         - {name: 'rh-ruby22', state: 'latest'}
         - {name: 'rh-python35', state: 'latest'}
  3. Manage SCL Python PIPs via pip module

    Each entry requires a hash with:

    • ruby_ver(required)
    • name(required)
    • state(optional)[defaults: present]
    • version(optional)[defaults: omit]
    roles:
     - role: ansible-role-scl
       scl_python_pips
         - {
           python_ver: 'rh-python35',
           name: 'snakeoil',
           state: 'present',
         }
  4. Manage SCL Ruby GEMs via gem module

    Each entry requires a hash with:

    • python_ver(required)
    • name(required)
    • state(optional)[defaults: present]
    • version(optional)[defaults: omit]
    • source(optoinal)[defaults: omit]
    • pre_release(optional)[defaults: no]
    roles:
     - role: ansible-role-scl
       scl_ruby_gems
         - {
           ruby_ver: 'rh-ruby23',
           name: 'fast_github',
           state: 'present',
         }
  5. AIO Example

    - role: ansible-role-scl
       scl_wrappers:
         - {collection: 'rh-ruby23', command: 'ruby'}
         - {collection: 'rh-python35', command: 'python'}
       scl_packages:
         - {name: 'rh-ruby23', state: 'latest'}
         - {name: 'rh-python35', state: 'latest'}
       scl_ruby_gems:
         - {
           ruby_ver: 'rh-ruby23',
           name: 'fast_github',
           state: 'present',
         }
       scl_python_pips:
         - {
           python_ver: 'rh-python35',
           name: 'snakeoil',
           state: 'present',
         }
  6. Ansible include_role notation(s)

    Examples of including roles and tasks from the SCL Role using the new include_role module in Ansible 2.2+

    These examples give Ansible a more modular, class like feel which allows portions of a role to be included inside of additional playbooks with less duplication

    tasks:
      - name: "Add wrapper script for rh-ruby22"
        include_role:
          name: ansible-role-scl
          tasks_from: wrappers
        vars:
          scl_wrappers:
            - {collection: 'rh-ruby22', command: 'ruby'}
    
      - name: "Install rh-ruby22 from SCL"
        include_role:
          name: ansible-role-scl
          tasks_from: packages
        vars:
          scl_packages:
            - {name: 'rh-ruby22'}
    
      - name: "Install gems for rh-ruby22"
        include_role:
          name: ansible-role-scl
          tasks_from: gems
        vars:
          scl_ruby_gems:
            - {
              ruby_ver: 'rh-ruby22',
              name: 'fast_github',
              state: 'present',
            }

Development / Contributing

See Contributing.

Note: This role is currently only tested against the following OS and Ansible versions:

Operating Systems / version

  • CentOS 6.x
  • CentOS 7.x

Ansible Versions

  • 2.9.0

License

Licensed under the MIT License. See the LICENSE file for details.

Author Information

  • Steven Bambling

About

This role installs and manages the SCL Software Collections repository, packages/collections for Fedora, CentOS, and Scientific Linux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published