Getting started

Ansible local facts

The debops.golang role provides a set of Ansible local facts at the ansible_local.golang.* namespace. The facts can be used to determine the location of the Go application binaries - installation from APT package or from source can result in different binary location (/usr/bin/ vs /usr/local/bin/) which might require different path specification in systemd unit files, for example.

Example inventory

To configure a Go environment on a given host or set of hosts, they need to be added to [debops_service_golang] Ansible group in the inventory:

[debops_service_golang]
hostname

The role will install Go development environment by default if no other Go packages are defined via golang__dependent_packages variable, by other Ansible roles.

Example playbook

If you are using this role without DebOps, or you want to use it as a dependency for another Ansible role, here's an example Ansible playbook that uses the debops.golang role:

---

- name: Manage Go environment
  collections: [ 'debops.debops', 'debops.roles01',
                 'debops.roles02', 'debops.roles03' ]
  hosts: [ 'debops_service_golang' ]
  become: True

  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'

  roles:

    - role: keyring
      tags: [ 'role::keyring', 'skip::keyring', 'role::golang' ]
      keyring__dependent_gpg_user: '{{ golang__keyring__dependent_gpg_user }}'
      keyring__dependent_gpg_keys:
        - '{{ golang__keyring__dependent_gpg_keys }}'

    - role: apt_preferences
      tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
      apt_preferences__dependent_list:
        - '{{ golang__apt_preferences__dependent_list }}'

    - role: golang
      tags: [ 'role::golang', 'skip::golang' ]