Hello Folk,
Need one help in updating the key to sshd_config file depending on the OS version.
I ve folder structure like below
- roles
- sshd
- tasks
main.yml - vars
main.yml - template
main.yml
I want to update /template/main.yml like
{% if ansible_distribution_major_version == “8”}
Insert RHEL8 KEY etc/ssh/sshd_config
{% if ansible_distribution_major_version == “7”}
Inset RHEL7 KEY to etc/ssh/sshd_config
{% if ansible_distribution == “Amazon” }
Inset Amazon KEY to etc/ssh/sshd_config
{% endif %}
my tasks/main.yml
- name : Update the key in sshd_config
template:
src: template/sshd.conf.j2
dest: /etc/ssh/sshd_config
Can I write KEY in Vars/main.yml and update the /etc/ssh/sshd_config file. The above is my approach till now but please somebody help me how can I update the sshd_config file with the key.
Like in /vars/main.yml
RHEL8_KEY = xyz
RHEL7_KEY = abc
RHEL6_KEY = mno
AMAZON_KEY = amazon
Regards