ansible , refer system variable inside role\'s task folder examp
文章来源: Unix19982023-05-07 13:39:51

---
- name: Hello User
  debug:
    msg: "Hello User {{ username | upper }}! You are a {{ sx }} and your fullname is {{ userfull | upper }}."
    msg: "{{ansible_env.USER}} is test_string1234 inside now"
    #msg: "test 2is {{ ansible_user }} "
  #when: "mxu_test".startswith('test')
  when:  ansible_env.USER.startswith('test')

 

##############################

if Linux user starts with string 'test; , it will show the msg:

  msg: "{{ansible_env.USER}} is test_string1234 inside now"