Add error checking to extra hosts links keys
See original GitHub issueIssue Type
- Bug report
Molecule and Ansible details
$ ansible --version && molecule --version
ansible 2.7.8
config file = None
configured module search path = [u'/Users/tomasz/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Users/tomasz/Library/Python/2.7/lib/python/site-packages/ansible
executable location = /Users/tomasz/Library/Python/2.7/bin/ansible
python version = 2.7.15 (default, Feb 12 2019, 12:27:02) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)]
molecule, version 2.19.0
Molecule installation method:
- pip
Ansible installation method:
- pip
Detail any linters or test runners used:
- No linters and tests, problem occurs when creating $MOLECULE_EPHEMERAL_DIRECTORY directory.
Desired Behavior
I’m trying to configure symlinks to inventory file (hosts), group_vars and host_vars of my prod environment:
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance1
image: ubuntu:18.04
groups:
- haproxy-group
- name: instance2
image: ubuntu:18.04
groups:
- haproxy-group
provisioner:
name: ansible
log: true
inventory:
links:
hosts: ../../../../env/live/inventory/hosts
group_vars: ../../../../env/live/inventory/group_vars
host_vars: ../../../../env/live/inventory/host_vars
env:
ANSIBLE_ROLES_PATH: ../../../../roles/
playbooks:
converge: ../../haproxy.yml
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
Actual Behaviour
$ molecule --debug converge
--> Validating schema /Users/tomasz/ansible-playbooks/haproxy/molecule/default/molecule.yml.
Validation completed successfully.
--> Test matrix
└── default
├── dependency
├── create
├── prepare
└── converge
--> Inventory /Users/tomasz/ansible-playbooks/haproxy/molecule/default/../../../../env/live/inventory/group_vars linked to /var/folders/1r/bt9yc5vd7fd0k8sqvw73xs900000gn/T/molecule/haproxy/default/group_vars
--> Inventory /Users/tomasz/ansible-playbooks/haproxy/molecule/default/../../../../env/live/inventory/hosts linked to /var/folders/1r/bt9yc5vd7fd0k8sqvw73xs900000gn/T/molecule/haproxy/default/hosts
Traceback (most recent call last):
File "/Users/tomasz/Library/Python/2.7/bin/molecule", line 10, in <module>
sys.exit(main())
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/molecule/command/converge.py", line 112, in converge
base.execute_subcommand(scenario.config, action)
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/molecule/command/base.py", line 100, in execute_subcommand
return command(config).execute()
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/molecule/command/base.py", line 51, in __init__
self._setup()
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/molecule/command/base.py", line 93, in _setup
self._config.provisioner.manage_inventory()
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/molecule/provisioner/ansible.py", line 633, in manage_inventory
self._link_or_update_vars()
File "/Users/tomasz/Library/Python/2.7/lib/python/site-packages/molecule/provisioner/ansible.py", line 718, in _link_or_update_vars
os.symlink(source, target)
OSError: [Errno 17] File exists
However, the symlink is actually created in $MOLECULE_EPHEMERAL_DIRECTORY:
$ ll $MOLECULE_EPHEMERAL_DIRECTORY
total 32
-rw-r--r-- 1 tomasz staff 151B Mar 18 11:00 Dockerfile_ubuntu_18_04
-rw-r--r-- 1 tomasz staff 239B Mar 18 11:03 ansible.cfg
-rw-r--r-- 1 tomasz staff 713B Mar 18 11:03 ansible_inventory.yml
lrwxr-xr-x 1 tomasz staff 117B Mar 18 11:03 group_vars -> /Users/tomasz/ansible-playbooks/haproxy/molecule/default/../../../../env/live/inventory/group_vars
lrwxr-xr-x 1 tomasz staff 112B Mar 18 11:02 hosts -> /Users/tomasz/ansible-playbooks/haproxy/molecule/default/../../../../env/live/inventory/hosts
-rw-r--r-- 1 tomasz staff 85B Mar 18 11:03 state.yml
Everything works fine when I comment out:
hosts: ../../../../env/live/inventory/hosts
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Using --add-host or extra_hosts with docker-compose
I am using docker-compose to run a test environment, that consists of about 5 different containers.
Read more >Using the Add-Host Flag for DNS Mapping within Docker ...
The --add-host flag is used to add a single host to IP mapping within a Docker container. This flag can be useful when...
Read more >Compose file version 3 reference - Docker Documentation
Top-level keys that define a section in the configuration file such as build , deploy ... Add metadata to the resulting image using...
Read more >Can I automatically add a new host to known_hosts?
Set the StrictHostKeyChecking option to no , either in the config file or via -o : ssh -o StrictHostKeyChecking=no username@hostname.com.
Read more >Advanced configuration - GitLab Docs
In GitLab 14.3 and later, this value determines if the runner should use strict host key checking. Default is true . In GitLab...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just by reading this, what is strange is that the links should be created under
$MOLECULE_EPHEMERAL_DIRECTORY/inventory
not directly under$MOLECULE_EPHEMERAL_DIRECTORY
. I’ll try to look more into it.Thanks for the information. I’ll test this tomorrow with 2.20 or devel.