The commented section of the following code works.  I was trying to 
simplify it by adding with_items; however, it seems to change the way it is 
evaluated?... at least that is my guess based on the verbosity:
skipping: [ansible-oel6] => (item=ansible)  => {
    "changed": false,
    "item": "ansible",
    "skip_reason": "Conditional result was False"
}

Playbook.
---
# tasks file for PS1_customize
- name: Appending customization to /etc/bashrc.  Logout/in to see changes
  blockinfile:
    path: /etc/bashrc
    backup: no
    marker: "# {mark} ANSIBLE MANAGED BLOCK - ps1_customizations"
    block: |

      #If id command returns zero, you've root access.
      if [ $(id -u) -eq 0 ]; then # set red color prompt for root
        PS1="\\[$(tput setaf 1)\\]\\u@\\h:\\w # \\[$(tput sgr0)\\]"
      elif [ $(id -u) -eq 4000  ]; then
        # Configure special user with green
        PS1="\[$(tput bold)\]\[$(tput setaf 2)\]\\u@\\h:\\w \\$ \[$(tput 
sgr0)\]"
      else
        PS1="\\u@\\h:\\w \$ "
      fi
  when: ansible_hostname | lower | search("item")
#  when: ansible_hostname | lower | search("prod") or
#        ansible_hostname | lower | search("backup") or
#        ansible_hostname | lower | search("nfs") or
#        ansible_hostname | lower | search("ansible")
  with_items:
    - prod
    - backup
    - nfs
    - ansible
  failed_when: false

So, I have a couple of questions.
1.  What would be the proper way to see if the hostname contains "splat" 
using with_items?  
2.  What would be the reverse of this?  (ie not in, or not contained, etc)

In summary, I am setting production and a list of other servers to red (for 
root user prompt).  On non-production servers, I will be setting it to 
yellow (hence the reason for question #2).

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/12ce80a6-bc0e-4edd-b903-1e4fa44e6546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to