Comments (14)
Don't know i'm afraid. I have used test-kitchen extensively with chef and puppet and a little with ansible but not used http proxies.
I suppose need to first run with say chef using maybe my sample chef repo
https://github.com/neillturner/chef-repo
the .kitchen.yaml file is in folder site-cookbooks/mycompany_webserver.
then test with a proxy and check that it works with chef.
Then test with ansible and see if it works or not with the same proxies.
If not this need to fix. my code does not do anything for proxies i guess i'm hoping that test-kitchen handles it.
Currently do a puppet contract using the kitchen-puppet plugin. Maybe next week i might get some time to look at this. I have a couple of other pulls request for kitchen-ansible as well.
from kitchen-ansible.
I tracked down this issue. The environment variables for http_proxy
and https_proxy
are getting prepended to the return value of kitchen-ansible's install_command method
. In some cases the return of the install_command
method begins with this:
if [ ! $(which ansible) ]; then
which gets turned into something like this by test-kitchen:
env http_proxy=http://example.com/ https_proxy=http://example.com/ if [ ! $(which ansible) ]; then
which results in a bash syntax error. The super hacky fix is to simply put a bash command ahead of the if
that tolerates the addition of a string like env http_proxy=http://example.com/ https_proxy=http://example.com/
. For testing I just added a simple echo
command above the if
statement which fixed the failure.
Now, with that in mind, I don't think the http_proxy settings will actually be used during the installation of ansible since the return string consists of many lines and it appears that test-kitchen's env_cmd method
assumes it will be a single line string. You could do all sorts of workarounds for this, but for starters do you see any path for paring down what is returned by kitchen-ansible's install_command method
? If it's somehow possible to get the return value down to a single string (perhaps by doing more of the logic for OS detection in Ruby?) then it will behave as test-kitchen expects it to.
And thanks for creating kitchen-ansible -- it's really nice to have an quick way to use Test Kitchen as I begin experimenting with Ansible coming from a Chef background.
from kitchen-ansible.
I know this issue. had same issue in kitchen-puppet. The driver preprend the http_proxy and https_proxy values to an env command and then call the install script. This is tough to get working when the install scripts get big.
In kitchen puppet I support have http_proxy and https_proxy in the provisioner as it easier that way. I put it in kitchen-ansible as some as i get time.
from kitchen-ansible.
if things get too tricky to solve another way, we could always try prepending with /bin/sh -c "
, but that would make quote escaping an issue. The other option is use bash HEREDOC with a unique identifier like: <<EOTESTKITCHENINSTALLCOMMAND
. Not sure since I've never messed with proxies very much, and am not sure how the rpm
command behaves with these env
vars set... Since it's setting them with env
rather than the export
shell builtin, I don't think they'd actually affect a subshell, in which case my suggestion is invalid.
from kitchen-ansible.
Yes. in kitchen-puppet i found it easier to add the http_proxy and https_proxy parameters to the provisioner part of kitchen.yaml and then put them in the commands individually in the install parts of the code. I think this approach will work for ansible just have not had time to do it. -)
from kitchen-ansible.
@neillturner It looks like this is the diff where you added http_proxy support to kitchen-puppet. Fair to say this is a good template for what needs to happen in kitchen-ansible?
neillturner/kitchen-puppet@0.0.17...0.0.18
from kitchen-ansible.
yes it is. I added http_proxy support to kitchen-puppet as i needed it on a contract i was doing using puppet and aws. I will see if i get time this week and next contract will involve ansible so i may well get time to do it.
Most of the enhancements beyond my initial development on kitchen-ansible have come from other people via pull requests which is great. -)
i do contracting using chef, puppet or ansible with AWS, openstack, vcloud etc and one of the great things about test-kitchen and its plugin architecture is i can use the same tooling on all these contracts.
from kitchen-ansible.
this is now support in kitchen-ansible 0.0.25
from kitchen-ansible.
👍 confirmed working with kitchen-ansible 0.0.25 from rubygems.org. Thanks!
from kitchen-ansible.
There seems to have been a regression, I'm seeing the same issue as originally reported.
My setup is:
- kitchen-ansible
- kitchen-docker
extract:
Installing ansible, will try to determine platform os
bash: -c: line 0: syntax error near unexpected token `then'
bash: -c: line 0: `env http_proxy=http://10.0.2.2:3128 https_proxy=http://10.0.2.2:3128 if [ ! $(which ansible) ]; then'
>>>>>> Converge failed on instance <default-centos-67>.
>>>>>> Please see .kitchen/logs/default-centos-67.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [env http_proxy=http://10.0.2.2:3128 https_proxy=http://10.0.2.2:3128 if [ ! $(which ansible) ]; then
if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ]; then
if ! [ grep -q 'Amazon Linux' /etc/system-release ]; then
if [ ! $(which ansible) ]; then
from kitchen-ansible.
I don't support putting http_proxy and/or https_proxy in the driver stanza of the .kitchen.yml
you should specify then n the provisioner stanza.
are you specifying in driver or provisioner stanzas?
from kitchen-ansible.
In the driver, @neillturner, as I need to set an HTTP proxy during the Docker build.
If I added it in the provisioner only, the docker driver would fail before it even got to the ansible provisioner.
I'm happy to create a PR, do you have any advice on how to approach this issue?
from kitchen-ansible.
try specifying the platform as it won't do the if statements
ie in the kitchen.yml
ansible_platform: centos
ie one of debian', 'ubuntu' 'redhat', 'centos', 'fedora' 'amazon' 'suse', 'opensuse', 'sles'
from kitchen-ansible.
added an extra initial blank line to the beginning of the install scripts and this allows the driver env variable to work at least for the install command.
so closing. fixed in version 0.40.1
from kitchen-ansible.
Related Issues (20)
- kitchen-ansible fails install due to docs on ruby2.6 HOT 6
- Setting `additional_copy_role_path` causes error on second run of `kitchen converge` HOT 1
- Kitchen 2.x: Could not load the 'ansible_playbook' provisioner from the load path. HOT 5
- Support for pip3 HOT 1
- kitchen user with zsh shell breaks ssh connection HOT 3
- Path for Temporary Test Kitchen Files and Busser HOT 1
- Failure when using busser_bin HOT 1
- [Error] Issues while using ansible mysql_db and mysql_user modules
- Allow ansible_vault_password_file to come from environment or the internet
- shell command produces different results
- Could not load the 'ansible_playbook' provisioner from the load path HOT 1
- CentOS/RHEL 8 support HOT 1
- test-kitchen supporters wanted HOT 2
- Can't find role when using roles_path option in kitchen.yml HOT 2
- Ubuntu 20.04 ppa has no ansible HOT 4
- Clear Linux Install Error HOT 1
- RDoc parser error in 0.56.0 for alpine.rb (Ruby 2.6.7)
- Unable to run community commands HOT 2
- Define collections download path
- Possible upcoming breaking change
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kitchen-ansible.