cancel
Showing results for 
Search instead for 
Did you mean: 
spurs
Flight Engineer
Flight Engineer
  • 800 Views

Jinja2 template for motd

Jump to solution

I just did motd lab by using jinja2 template.

the template is like

-------------

this is the system {{ ansible_facts['fqdn'] }}.

blashblashblash like first line there are more ansible_facts variables.

-------------

the playbook is like

-------------------- 

(for serverA)

name:  ~~~

template:

  src: motd.j2

  dest: /etc/motd

  owner: root

------------------

I understand the template should display ansible_facts variables.

However, I don't get how this template displayed when I logged in to serverA by SSH.

Is template module is not like file or copy module? 

I was expecting motd.j2 will be copied at /etc/motd on serverA, but it actually displayed the context of template when I logged-in, which was impressive!

Can someone please explain this?

Labels (1)
1 Solution

Accepted Solutions
Chetan_Tiwary_
Community Manager
Community Manager
  • 733 Views

@spurs   The message of the day (MOTD ) is used to communicate information to end users, the contents of /etc/motd are displayed after a successful login but just before it executes the login shell.

https://man7.org/linux/man-pages/man5/motd.5.html#:~:text=The%20contents%20of%20%2Fetc%2Fmotd,than%2...

So, when you configured the motd in servera and logs in via ssh - it showed you the motd before giving you a login shell 

Chetan_Tiwary__0-1704132586226.png

 

View solution in original post

0 Kudos
1 Reply
Chetan_Tiwary_
Community Manager
Community Manager
  • 734 Views

@spurs   The message of the day (MOTD ) is used to communicate information to end users, the contents of /etc/motd are displayed after a successful login but just before it executes the login shell.

https://man7.org/linux/man-pages/man5/motd.5.html#:~:text=The%20contents%20of%20%2Fetc%2Fmotd,than%2...

So, when you configured the motd in servera and logs in via ssh - it showed you the motd before giving you a login shell 

Chetan_Tiwary__0-1704132586226.png

 

0 Kudos
Join the discussion
You must log in to join this conversation.