Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap ansible-playbook command in a shell script #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chris48s
Copy link
Collaborator

This PR adds a deploy script and stores the locations of inventory.ini and variables.yml in a .env file. I've got mine set to

INV_FILE="../metrics-shields-io-config-vault/inventory-metrics.shields.io.ini"
EXTRAS_FILE="@../metrics-shields-io-config-vault/variables-metrics.shields.io.yml"

Then we can run

./deploy.sh --tags=grafana

(we can also pass other extra ad-hoc args to ansible if we need)

which is a bit easier than

ansible-playbook shields-io-metrics.yml -i ../metrics-shields-io-config-vault/inventory-metrics.shields.io.ini -e @../metrics-shields-io-config-vault/variables-metrics.shields.io.yml --tags=grafana --ask-vault-pass --ask-become-pass

This will also make it easier if we need to change the standard args we pass to ansible-playbook over time.

If you're happy with this approach, let me know. I will update the documentation in this PR before we merge it.

@platan
Copy link
Owner

platan commented Jul 27, 2020

I like your idea and we can continue this approach. Works properly :-)

(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) ./deploy.sh --tags=grafana
File .env does not exist. Run 'cp .env.template .env'
(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) cp .env.template .env
(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) ./deploy.sh --tags=grafana
INVENTORY_FILE is not defined. Set INVENTORY_FILE in .env
(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) vim .env
(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) ./deploy.sh --tags=grafana
EXTRAS_FILE is not defined. Set EXTRAS_FILE in .env
(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) vim .env
(venv) ➜  metrics-shields-io-config git:(ansible-wrapper) ./deploy.sh --tags=grafana
BECOME password:

@platan
Copy link
Owner

platan commented Jul 27, 2020

I guess you have an INVENTORY_FILE variable in your .env file, not INV_FILE.

@platan
Copy link
Owner

platan commented Jul 27, 2020

I've just added -e @versions.json to all example commands in README in master branch.

@platan
Copy link
Owner

platan commented Sep 13, 2020

Currently you have to use -e @versions.yml instead of -e @versions.json :-).

@chris48s
Copy link
Collaborator Author

Indeed :) I've updated that and rebased to resolve the merge conflicts on the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants