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.
- Ansible
- Maintainer access with SSH keys setup for GitLab, Lagoon.
git clone https://github.com/grahamethompson/lagoon_inventory.git
cd lagoon_inventory
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
Edit ./roles/lagoon/defaults/main.yml
to add your lagoon GraphQL endpoint.
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
Edit ./roles/gitlab/defaults/main.yml
to add your Gitlab Personal access token and add your GitLab URL and api version settings.
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 from Lagoon and Gitlab and save the response to /logs
ansible-playbook playbooks/get_project_info.yml
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
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