Yeah! I fixed my issue, thank you very much. After I changed the tail of file from .j2 to .set, my playbook worked fine.
But now, I have another problem, when run my playbook with config.set: set interfaces ge-/0/0/5.1 family inet address 1.1.1.1/32 set interfaces ge-/0/0/5.1 vlan-id 51 ===> FAIL Then I changed as below: set interfaces ge-/0/0/5.1 vlan-id 51 set interfaces ge-/0/0/5.1 family inet address 1.1.1.1/32 ===> OK Its mean that when one comment run, system will commit immediately and then implement the next comment. So How I can do to commit comment after all? Regards, *********************************************************************************** *Đào Minh Đạt* Mail: [email protected] Tel: 01265 332 116 Add: 16/72/11, Nguyễn Thiện Thuật, phường 3, Quận 3, Tp.Hồ Chí Minh *********************************************************************************** 2017-03-13 8:47 GMT+07:00 Dat Dao <[email protected]>: > Dear Peter, > Thanks for your response, but can you explain about the argument src in > the junos_template. > I don't know what do we fill after src's colon? the path or the file name? > In my ansible, I creat config.j2 at /etc/ansible folder. > So Can I fill: > src: /etc/ansible/config.j2 > Or: > src: config.j2 > > And I have another problem, I read junos_template'documentation, at the > src entry wrote below: > "The path to the config source. The source can be either a file with > config or a template that will be merged during runtime. By default the > task will search for the source file in role or playbook root folder in > templates directory." > > So it's mean the config soure must to be create at /etc/ansible/roles? > > > Regards, > > ************************************************************ > *********************** > *Đào Minh Đạt* > Mail: [email protected] > Tel: 01265 332 116 > Add: 16/72/11, Nguyễn Thiện Thuật, phường 3, Quận 3, Tp.Hồ Chí Minh > ************************************************************ > *********************** > > 2017-03-13 3:21 GMT+07:00 Peter Sprygada <[email protected]>: > >> only include configuration statements in your file (config.j2), not cli >> commands. remove the configure and commit statements >> >> On Sun, Mar 12, 2017 at 11:39 AM, Dat Dao <[email protected]> wrote: >> >>> Hi IAN, >>> I am a newbie in ansible sector, I wrote the playbook in which I >>> used junos_template module, but when I run playbook, I got this error: >>> he error is "msg": "Unable to load config: ConfigLoadError(severity: >>> error, bad_element: junos.set, message: error: unknown command)" which is >>> odd since using the juniper_config module with the lines: - set system >>> host-name {{ inventory_hostname }} works fine. >>> >>> This is my jinja2 file: >>> >>> configure >>> set system hostname DAT123 >>> commit >>> >>> and here is my playbook: >>> --- >>> - name: cau hinh doi hostname >>> hosts: juniper >>> >>> >>> tasks: >>> - name: tai config >>> junos_template: >>> src: config.j2 >>> host: 100.100.100.100 >>> >>> Please help me fix this issue. >>> >>> >>> Vào 00:10:44 UTC+7 Thứ Sáu, ngày 13 tháng 5 năm 2016, Ian Cote đã viết: >>>> >>>> I've been kicking the tires on 2.1, specifically to start managing >>>> network equipment. I've had success with the junos_command and >>>> junos_config modules, but cannot get the junos_template module to work for >>>> even a trivial example. I've tried the set and text formats - >>>> >>>> config.set: >>>> set system host-name {{ inventory_hostname }} >>>> >>>> config.j2 (which according to the -vvv output was treated as text): >>>> system { >>>> host-name {{ inventory_hostname }} >>>> } >>>> >>>> The error is "msg": "Unable to load config: ConfigLoadError(severity: >>>> error, bad_element: junos.set, message: error: unknown command)" which is >>>> odd since using the juniper_config module with the lines: - set system >>>> host-name {{ inventory_hostname }} works fine. >>>> >>>> Could someone post a (preferably text form) juniper template that they >>>> have had success with? I'm looking to merge the config here at first. >>>> >>>> Thanks, >>>> -ian >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ansible Project" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/ansible-project/c34975a6-0c04-491e-b20a-259115e73ca7%40g >>> ooglegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/c34975a6-0c04-491e-b20a-259115e73ca7%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Ansible Project" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/to >> pic/ansible-project/l2b3Gy41UGI/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit https://groups.google.com/d/ms >> gid/ansible-project/CAEkdrMhkpFVLUbDvC8xQfZowbYVQtyMeEzpsarh >> Bu-%2BB4FVK%2Bg%40mail.gmail.com >> <https://groups.google.com/d/msgid/ansible-project/CAEkdrMhkpFVLUbDvC8xQfZowbYVQtyMeEzpsarhBu-%2BB4FVK%2Bg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEq8euJoMEvgnrsoHAHcho-BqfHfuO7YouLOqn0Or28Afsugzg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
