Giter VIP home page Giter VIP logo

Comments (14)

neillturner avatar neillturner commented on June 29, 2024

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.

jalessio avatar jalessio commented on June 29, 2024

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.

neillturner avatar neillturner commented on June 29, 2024

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.

trinitronx avatar trinitronx commented on June 29, 2024

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.

neillturner avatar neillturner commented on June 29, 2024

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.

jalessio avatar jalessio commented on June 29, 2024

@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.

neillturner avatar neillturner commented on June 29, 2024

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.

neillturner avatar neillturner commented on June 29, 2024

this is now support in kitchen-ansible 0.0.25

from kitchen-ansible.

jalessio avatar jalessio commented on June 29, 2024

👍 confirmed working with kitchen-ansible 0.0.25 from rubygems.org. Thanks!

from kitchen-ansible.

jsok avatar jsok commented on June 29, 2024

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.

neillturner avatar neillturner commented on June 29, 2024

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.

jsok avatar jsok commented on June 29, 2024

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.

neillturner avatar neillturner commented on June 29, 2024

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.

neillturner avatar neillturner commented on June 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.