Template to include contents of another file

61 views
Skip to first unread message

Mark Maas

unread,
Mar 26, 2014, 6:21:35 AM3/26/14
to ansible...@googlegroups.com
Dear List,

I'm trying to have a template placed on some servers and while the file is beeing placed to contain the contents of another file (Public key) like so:

encapmodule-properties.j2:
encap-public-key={% include '/opt/encapserver.crt' %}
assertion-time-skew=5
registrationIdLdapAttrName=binckMobileDeviceID
includeSignatureValidation=true
includeBeforeAndAfterValidation=true
includeIssuerValidation=false
includeStatusCodeValidation=false
expectedIssuer=encap

As you can see, I tried to include the "/opt/encapserver.crt" file on the machine beeing managed at that moment.

mmaas@xmgtansible:~/playbooks$ ansible-playbook forge_rock.yml -l t1atham* -vvvv --tags=test
But i'm running into this error:
TASK: [openam | Plaats binck_encapmodule.properties] **************************
<t1athamyar> ESTABLISH CONNECTION FOR USER: mmaas
<t1athamyar> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/mmaas/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 't1athamyar', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-1395828889.82-55430178152696 && chmod a+rx $HOME/.ansible/tmp/ansible-1395828889.82-55430178152696 && echo $HOME/.ansible/tmp/ansible-1395828889.82-55430178152696'"]
fatal: [t1athamyar] => {'msg': '/opt/encapserver.crt', 'failed': True}
fatal: [t1athamyar] => {'msg': '/opt/encapserver.crt', 'failed': True} 

Any idea's?

I could ofcourse simply "cat" the contents of that file and register the output as a variable. And then use that variabel. But that would not be as clean as when using jinja2 stuff directly ;-)

Thanks,
Mark

Brian Coca

unread,
Mar 26, 2014, 8:58:02 AM3/26/14
to ansible...@googlegroups.com
templates get composed locally and then copied to the target. You might want to use fetch/slurp on the file to have it available locally to include.

Mark Maas

unread,
Mar 26, 2014, 9:08:50 AM3/26/14
to ansible...@googlegroups.com
On Wednesday, March 26, 2014 1:58:02 PM UTC+1, Brian Coca wrote:
templates get composed locally and then copied to the target. You might want to use fetch/slurp on the file to have it available locally to include.

I tried that, sorta, by copying it to that location (/opt) on the "local" machine. Same error though... 
Reply all
Reply to author
Forward
0 new messages