--- - name: Automatically populate /etc/issue with environment name hosts: - dev - test - prod become: true tasks: - name: Determine environment name from inventory groups ansible.builtin.set_fact: env_name: >- {% if 'prod' in group_names %} Production {% elif 'test' in group_names %} Testing {% elif 'dev' in group_names %} Development {% endif %} - name: Populate /etc/issue ansible.builtin.copy: dest: /etc/issue content: | {{ env_name }} owner: root group: root mode: '0644'