Skip to content

Commit

Permalink
Merge pull request #2 from lunascat/master
Browse files Browse the repository at this point in the history
Fix handling of extra_vars
  • Loading branch information
jriguera committed Jan 18, 2018
2 parents 9e1c540 + a78c434 commit 2a591c6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pull base image
FROM alpine:3.4
FROM alpine:3.6
LABEL Description="Concourse Ansible resource" Vendor="SpringerNature Platform Engineering" Version="1.0"
MAINTAINER SpringerNature Platform Engineering platform-engineering@springernature.com

Expand All @@ -16,7 +16,7 @@ RUN ln -s /lib /lib64 \
xmlsec \
yaml \
libc6-compat \
python \
python3 \
libxml2 \
py-lxml \
py-pip \
Expand All @@ -28,20 +28,20 @@ RUN ln -s /lib /lib64 \
apk --upgrade add --no-cache --virtual \
build-dependencies \
build-base \
python-dev \
python3-dev \
libffi-dev \
openssl-dev \
linux-headers \
libxml2-dev

# Ansible installation
ADD requirements.txt /opt/
RUN pip install --upgrade --no-cache-dir -r /opt/requirements.txt
RUN pip3 install --upgrade --no-cache-dir -r /opt/requirements.txt

RUN apk del \
build-dependencies \
build-base \
python-dev \
python3-dev \
libffi-dev \
openssl-dev \
linux-headers \
Expand Down
6 changes: 3 additions & 3 deletions assets/out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
"""
Concourse out resource
Expand Down Expand Up @@ -119,7 +119,7 @@ class PlaybookCLI(CLI):
# Ansible 2.3.x
variable_manager = VariableManager()
if extra_vars:
variable_manager.extra_vars = load_extra_vars(loader=loader, options=extra_vars)
variable_manager.extra_vars = load_extra_vars(loader=loader, options=self.options)
variable_manager.options_vars = load_options_vars(self.options)
if host_vars:
variable_manager.host_vars_files = host_vars
Expand Down Expand Up @@ -362,7 +362,7 @@ class AnsiblePlaybook(Resource):
# Extra vars (just a dictionary)
extra_vars = config.get("extra_vars", {})
extra_vars.update(source.get("extra_vars", {}))
config['extra_vars'] = extra_vars
config['extra_vars'] = [extra_vars]
# Private key
private_key = source.get("private_key")
if private_key:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dopy==0.3.7
pysphere==0.1.7
python-consul==0.7.1
f5-sdk==2.3.3
bigsuds==1.0.4
bigsuds==1.0.6
netaddr==0.7.19
boto==2.48.0
azure==2.0.0
Expand Down
4 changes: 4 additions & 0 deletions tests/out.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"inventory": {
"path": "inventory",
"file": "inventory.ini"
},
"extra_vars": {
"var1": "hello, world!",
"var2": 42
}
},
"source": { }
Expand Down
8 changes: 8 additions & 0 deletions tests/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@

- name: ping2
ping:

- name: print var1
debug:
var: var1

- name: print var2
debug:
var: var2

0 comments on commit 2a591c6

Please sign in to comment.