Last active
February 16, 2018 12:23
-
-
Save childnode/50295370e2fc79a10847411826210de2 to your computer and use it in GitHub Desktop.
Ansible Bugreport 36243 - https://github.com/ansible/ansible/issues/36243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.Python | |
bin/ | |
include/ | |
lib/ | |
pip-selfcheck.json | |
playbook.retry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
docker build --tag childnode/bugreport-ansible-docker-container:latest -f Dockerfile $(dirname $0)/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[localhost] | |
127.0.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: "Bugreport 36243 - https://github.com/ansible/ansible/issues/36243" | |
connection: local | |
hosts: localhost | |
vars: | |
dstate: "{{state | default('started')}}" | |
env: { foo: 'bar', bar: 'foo', baz: 'zap' } | |
tasks: | |
- name: "inspect env for container has been changed {{result.changed}}" | |
local_action: shell {% raw %}docker inspect de.childno.bugreport.ansible-docker-container -f '{{.Config.Env}}'{% endraw %} | |
register: inspected | |
- name: "start container {{dstate}} with {{env}}" | |
docker_container: | |
name: "de.childno.bugreport.ansible-docker-container" | |
hostname: "de.childno.bugreport.ansible-docker-container" | |
image: "childnode/bugreport-ansible-docker-container:latest" | |
state: "{{dstate}}" | |
#restart: "omit" | |
#recreate: "omit" | |
pull: "false" | |
restart_policy: "unless-stopped" | |
# restart_retries: "omit" | |
# volumes: "omit" | |
# published_ports: "omit" | |
# exposed_ports: "omit" | |
env: '{{env}}' | |
# env_file: "omit" | |
# log_driver: "json-file" | |
# log_options: "{'max-file': '3','max-size': '200m'}" | |
# network_mode: "bridge" | |
# keep_volumes: "false" | |
# command: "omit" | |
# etc_hosts: "omit" | |
# user: "omit" | |
# privileged: "omit" | |
register: result | |
- debug: | |
msg: | |
- "was:" | |
- "{{inspected.stdout}}" | |
- "is now:" | |
- "{{result.ansible_facts.docker_container.Config.Env}}" | |
- "expected to match applied:" | |
- "{{env}}" | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
ansible-playbook playbook.yml --list-hosts | |
ansible-playbook playbook.yml -e state=present | |
ansible-playbook playbook.yml | |
#docker inspect de.childno.bugreport.ansible-docker-container -f "{{.Config.Env}}" | |
echo "show nothing changes if we do present again" | |
ansible-playbook playbook.yml -e state=present | |
#docker inspect de.childno.bugreport.ansible-docker-container -f "{{.Config.Env}}" | |
echo "show nothing changes if we start with different env, only containing one of the three envs defined before" | |
ansible-playbook playbook.yml -v -e '{"env": {foo: bar}}' | |
#docker inspect de.childno.bugreport.ansible-docker-container -f "{{.Config.Env}}" | |
echo "show changes if we start with different env, containing a different than one of the three envs defined before" | |
ansible-playbook playbook.yml -e '{"env": {changed: me}}' | |
#docker inspect de.childno.bugreport.ansible-docker-container -f "{{.Config.Env}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment