Create a Simple Software Repository for Ansible
Categories:
4 minute read , 25 minute provision
Projects: c2platform/rws/ansible-gis
,
c2platform.core
,
c2platform.wincore
,
c2platform.mw
Overview
This guide outlines the process adopted by RWS for managing software downloads
using Ansible. It follows the strategy described in
Designing a Flexible Software Repository for Ansible
and employs the c2platform.wincore.download
role for download operations. The
setup involves Vagrant and Ansible executing the following tasks:
- Vagrant employs the VirtualBox Provider to instantiate five VMs as specified in the table below.
- Using the Ansible Provisioner, Vagrant orchestrates an Ansible playbook
across these VMs to:
- Establish a Windows File Share on
gsd-ansible-file-share1
, populating it with a Tomcat tarball and a zip file. - Set up a software service,
gsd-ansible-repo
, which mounts the file share and hosts its contents via Apache2. - Initiate concurrent downloads on three nodes (
gsd-ansible-download1
,gsd-ansible-download2
,gsd-ansible-download3
), using HTTPS. Shared storage acts as a cache, facilitated bygsd-ansible-file-share1
. Thec2platform.wincore.download
role ensures that downloads are synchronized, with only one node downloading a file at any given time, determined by which node acquires a lock file first. There are two downloads, potentially handled by different nodes.
- Establish a Windows File Share on
Node | OS | Provider | Purpose |
---|---|---|---|
gsd-ansible-file-share1 | Windows 2022 Server | VirtualBox | Hosts file share for storing and caching downloads |
gsd-ansible-repo | Red Hat 9 | VirtualBox | Simple web-based software server using Apache2 |
gsd-ansible-download1 | Windows 2022 Server | VirtualBox | Executes test downloads |
gsd-ansible-download2 | Windows 2022 Server | VirtualBox | Executes test downloads |
gsd-ansible-download3 | Windows 2022 Server | VirtualBox | Executes test downloads |
Prerequisites
- Ensure your RWS Development Environment is set up on Ubuntu 22, as detailed here.
Setup
To prepare the complete environment, execute vagrant up for the specified VMs. On a high-performance development workstation, this setup should take approximately 25 minutes.
export BOX="gsd-ansible-repo gsd-ansible-file-share1 gsd-ansible-download1 \
gsd-ansible-download2 gsd-ansible-download3"
vagrant up $BOX
Verification
Successful execution of the playbook indicates that the download nodes (
gsd-ansible-download1
,gsd-ansible-download2
,gsd-ansible-download3
) managed to retrieve the Tomcat binaries. Review the final console output from Ansible, highlighting tasks like tasks Create download lock, Download install file, Extract zip and Remove lock file, to determine which node successfully acquired the lock and completed the download.Show me
TASK [c2platform.wincore.download : Create download lock] ********************** changed: [gsd-ansible-download1] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.tar.gz) ok: [gsd-ansible-download2] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.tar.gz) ok: [gsd-ansible-download3] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.tar.gz) changed: [gsd-ansible-download1] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.zip) ok: [gsd-ansible-download2] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.zip) ok: [gsd-ansible-download3] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.zip) TASK [c2platform.wincore.download : Download install file] ********************* changed: [gsd-ansible-download1] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.tar.gz) changed: [gsd-ansible-download1] => (item=//gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19.zip) TASK [c2platform.wincore.download : Extract zip] ******************************* changed: [gsd-ansible-download1] => (item=apache-tomcat-10.1.19.zip → //gsd-ansible-file-share1.internal.c2platform.org/ansible-repo/cache\apache-tomcat-10.1.19) TASK [c2platform.wincore.download : Remove lock file] ************************** changed: [gsd-ansible-download1] => (item=\\gsd-ansible-file-share1.internal.c2platform.org\ansible-repo\cache\e9e4e25175d60ab7bf720609971f81206c644ce950deed17bf6de78613cca091.lock → absent) changed: [gsd-ansible-download1] => (item=\\gsd-ansible-file-share1.internal.c2platform.org\ansible-repo\cache\4c6082b852ad235cb10bc50992259ddc1145664c6347b0ea97100cada66c5153.lock → absent)
Using the RWS FireFox profile navigate to https://gsd-ansible-repo.internal.c2platform.org/ . When prompted, log in with the username
ansible
and the passwordSupersecret!
. You should be able to view and download the Tomcat binaries, such asapache-tomcat-10.1.19.tar.gz
.Access
gsd-ansible-download1
via Remmina or VirtualBox Manager as thevagrant
user (password:vagrant
). Desktop shortcuts provide links to the file share and downloads. Thevagrant
user has full control over and access to the share.
Review
To understand the VM setup and configuration, review the Ansible Inventory and Vagrant project files, and the Ansible collections.
Ansible Inventory
Review the following files in the Ansible inventory / Vagrant project
c2platform/rws/ansible-gis
:
File(s) | Description |
---|---|
Vagrantfile and Vagrantfile.yml | Used by Vagrant for VM creation, network setup, etc. |
plays/mgmt/ansible_repo.yml | The primary Ansible playbook |
group_vars/ansible_file_share/* | Configuration for the file share node gsd-ansible-file-share1 |
group_vars/ansible_repo/* | Configuration for the web server node gsd-ansible-repo |
group_vars/ansible_download/* | Configuration for the download nodes gsd-ansible-download1 , 2 and 3 |
Ansible Collections / Roles
Collection | Description |
---|---|
c2platform.wincore | Includes essential roles for Windows hosts, such as c2platform.wincore.download . |
c2platform.core | Provides roles for Linux targets, e.g., c2platform.core.linux . |
c2platform.mw | Contains the apache role for web server setup. |
Next Steps
For development and experimentation, consider a stepwise approach using Ansible tags and Vagrant snapshots to manage and iterate on the environment more efficiently.
To provision a specific tag you just prefix the command with After each step you can create snapshots using Vagrant. Especially a snapshot
after There are other tags so for example if you only want to perform only the download and only from Show me
Tag Step Command Description v0
Create File Share TAGS=v0 vagrant up $BOX
Creates all nodes but only runs the Ansible provisioner on gsd-ansible-file-share1
.v1
Create Web Server TAGS=v1 vagrant provision $BOX
Run the provisioner on gsd-ansible-repo
. This creates the Apache2 based web server.v2
Download software TAGS=v2 vagrant provision $BOX
Runs Ansible on gsd-ansible-download[1:3]
TAGS=
for example to provision step v1
run the command:TAGS=v1 vagrant provision $BOX
v0
because node creation takes some time. This also includes
registration of the RHEL 9 based gsd-ansible-repo
and Sysprep of all Windows hosts.gsd-ansible-download1
TAGS=common,download vagrant up $BOX --provision | tee provision.log
Additional Information
For additional insights and guidance:
- Explore the design and advantages of this setup in Designing a Flexible Software Repository for Ansible.
- Learn about Vagrant’s capabilities in handling Sysprep for Windows and automated registration for RHEL 9 in the Vagrant setup guide.
- For an overview of the types of projects in Ansible, refer to Ansible Projects.
- To facilitate downloads using HTTPS without SSL/TLS errors a trust relationship is created by Ansible. Refer to Managing SSL/TLS Trust with Ansible on Windows Hosts for more information.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.