4. The principle of managing multiple envs
● Multiple environments (DEV, QA, STG, PRD)
● The same roles, playbooks, modules, ... in different version in different envs
● Each component has different development velocity
● Shift the components from lower to higher environments in controlled manner
DEV QA STG PRD
Role 1 t22 t10 t5 t3
Role 2 t19 t16 t11 t7
Playbook t10 t7 t4 t2
6. How to achieve it?
● Single monolithic Git repo?
○ No way!
● Git submodules?
○ Too tricky...
● Separate Git repos?
○ Hm...
○ What tool to use?
■ ansible-galaxy?
■ But that's only for roles! What about playbooks, inventories, modules, plugins, ...?
8. Android repo script
● Tool used for managing Android repositories
● Wrapper around Git
● Fetches whatever Git repos into a single work directory
● Individual repos stay as Git repos with all their history
● Integrates with Gerrit code review system
● Using Manifest file (XML)
○ Android Repo Manifest Management tool (armm)
11. How to use it?
# Get the repo script and make it executable
sudo curl -s 'https://gerrit.googlesource.com/git-repo/+/stable/repo?format=TEXT' |
base64 -d > /usr/local/bin/repo
chmod +x /usr/local/bin/repo
# Create the work directory and fetch all components
export ENV=dev
mkdir -p /tmp/ansible/env/$ENV
cd /tmp/ansible/env/$ENV
repo init -u https://github.com/jtyr/ansible-repo-test_manifest.git -b $ENV
repo sync --no-clone-bundle
12. Repo script commands
# Show all possible repo commands
repo help --all
# List all projects
repo list
# Show which files have been modified
repo status
# Show changes across all projects
repo diff
# Sync only particular project
repo sync my_project
# Run command across all projects
repo forall -p -c 'git add -A; git commit -m "My change"; git push'
14. Summary
● Keep Ansible components in separate Git repos
● Create an extra Git repo with a Manifest file for each environment
● Use the repo script to build the work directory