Ansible file edition with other file -
a lot of routers have template acl. first create config file each one, f.e. name kh.tb05
--- - name: populate configs (with object groups) template: src=kha_obj.j2 dest={{ config_dir }}/{{ item.obj }}.txt with_items: kha_routers_obj
but have additional rules, want place them in populated files. f.e. kh.tb05 populated config file, addkhtb05 file additional rules tried config, doesn't work.
- name: read file command: cat {{ item }} register: contents_{{ item }} with_fileglob: {{ config_dir }}/addkh.* - name: add together conf lineinfile: dest={{ item }} insertbefore='deny ip whatever log' line=contents_{{ item }}.stdout with_fileglob: {{ config_dir }}/kh.* state=present
update:
- name: read file command: cat {{ item }} register: contents with_fileglob: /etc/ansible/kha/roles/acl/templates/addkh.* - debug: contents
now plays, output strange.
task: [acl | debug contents.stdout] ******************************************* ok: [localhost] => { "msg": "hello world!" }
ansible
No comments:
Post a Comment