python - Ansible extra unquoted colon error -


hi following tutorial here https://pynet.twb-tech.com/blog/ansible/ansible-cfg-template-p2.html

my site.yml

--- - name: generate router configuration files   hosts: localhost   roles:     - router 

my tasks/main.yml

--- - name: generate configuration files   template: src=router.j2 dest=/lib/python2.7/site-packages/ansible/rtr-template/{{item.hostname}}.txt   with_items: testconfig 

my template (router.j2)

    no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime show-timezone service timestamps log datetime msec localtime show-timezone service password-encryption ! hostname {{item.hostname}} {{item.example}}  ! boot-start-marker boot-end-marker ! logging buffered 32000 no logging console 

my var(main.yml)

--- testconfig:  -{hostname: router123, example: no ip cef} 

when run following output, think there problem var formatting. unsure how fix it

error: syntax error while loading yaml script, /usr/lib/python2.7/site-packages/ansible/rtr-template/roles/router/vars/main.yml 

note: error may appear before position: line 3, column 32

testconfig: -{hostname: router123, example: no ip cef} ^ 1 looks easy fix. there seems unquoted colon in line , confusing parser. expecting find 1 free colon. solution add quotes around colon, or quote entire line after first colon.

for instance, if original line was:      copy: src=file.txt dest=/path/filename:with_colon.txt  can written as:      copy: src=file.txt dest='/path/filename:with_colon.txt'  or:      copy: 'src=file.txt dest=/path/filename:with_colon.txt' 

i think missing space between dash , {. guessing.

 - {hostname: router123, example: no ip cef} 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -