Skip to content

grahamethompson/lagoon_inventory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible inventory generator for Lagoon

Ansible playbook and supporting files to generate an inventory of hosts for projects hosted in an Amazee.io Lagoon.

Hosts are grouped by Lagoon metadata.

Requirements

Setup

Clone the repo locally

git clone https://github.com/grahamethompson/lagoon_inventory.git
cd lagoon_inventory

Symlink roles

Anisble Playbooks access roles from their folder, but I'd want to keep the project dir clean. So symlink /roles into /playbooks/roles

ln -s ../roles playbooks/roles

Configure Lagoon GraphQL URL

Edit ./roles/lagoon/defaults/main.yml to add your lagoon GraphQL endpoint.

Configure connection settings for Lagoon SSL

Edit ./group_vars/al.yml with your Lagoon cloud config to connect to your projects.

ansible_host: ssh.lagoon.amazeeio.cloud
ansible_port: 32222
ansible_connection: ssh

Configure Gitlab API

Edit ./roles/gitlab/defaults/main.yml to add your Gitlab Personal access token and add your GitLab URL and api version settings.

Playbooks

Setup hosts

Populate your inventory file with hosts of production environments in Lagoon. Lagoon GraphQL API metadata is used to fetch active projects and construct the hosts.

ansible-playbook playbooks/populate_inventory.yml

The hosts/inventory.yml file will be organised into groups based on project metadata. Python valid names require "-" and "." are converted to "_".

Get Project info

Get project info from Lagoon and Gitlab and save the response to /logs

ansible-playbook playbooks/get_project_info.yml 

Clone projects

Clone gitlab projects to the ./projects folder for subsequent patching etc.

The drupal versions of projects can be set in the 'Git clone Gitlab project repos by filter' task. Arbitrary tags from github can also be used to clone which ever project is required.

ansible-playbook playbooks/clone_projects.yml

Known issues

Shared connection to ssh-lagoon.govcms.amazee.io closed.
Without Python installed on production containers Ansible's `raw` module must be used to execute commands on remote hosts. This produces a `Shared connection closed message` on each request. There are multiple issues on open https://github.com/ansible/ansible/issues/25941

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published