Я пытаюсь вставить строку в файл после того, как он соответствует регулярному выражению в последний раз.
Это фактически добавляет строку, но в конце файла.
tasks:
- name: add to ansible hosts file
lineinfile:
dest: "hosts"
insertafter: '^\[ansible_ssh_host\]'
line: " test ansible_ssh_host=172.0.0.3"
Я хочу добавить его после последней строки, содержащей "ansible_ssh_host"
Файл назначения
ansible-server ansible_ssh_host=172.0.0.1
template-server ansible_ssh_host=172.0.0.2
[tag_ansible-servers]
ansible-server
[tag_template-servers]
template-server