Thank you for all your help always .. I found the solution for the above
{% if ansible_distribution_major_version == "8"}
{{ RHEL8_KEY }}
{% if ansible_distribution_major_version == "7"}
{{ RHEL7_KEY }}
{% if ansible_distribution == "Amazon" }
{{ AMZN_KEY }}
{% endif %}
On Tue, Jul 12, 2022 at 1:12 PM Prady A <[email protected]> wrote:
> 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
>
>
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAEuB3AoYxMXLFRdVAxg4-tOG-%2B4UN%2B6fjOtiD6CFdeKXcu%2B0bg%40mail.gmail.com.