Hi Team,
I am trying to create a playbook to add the allow users and hostname dynamically in SSHD config. Ansible playbook should check the entry and add it if its not exist.
I have written the below code and it is duplicating the same content and its not checking idempotent. The below code is not adding @ *@dcecpn0.spt.com. Can you please check and provide your suggestions.
lineinfile:
path: “{{ security_ssh_config_path }}”
backrefs: yes
regexp: ‘(^AllowUsers(?!.b{{ security_ssh_allowed_users }}@{{ security_ssh_allowed_hosts }}\b).)$’
line: ‘\1 {{ security_ssh_allowed_users }}@{{ security_ssh_allowed_hosts }}’
state: present
Thanks
Amit.