---
- name: Testing
  hosts: localhost
  become_user: "{{ User }}"
  become: false
  tasks:
  # Comment
     - name: Check user
       block:
         - name: Execute user check (abcd)
           shell: |
             grep -v "^a_radmin:" /etc/passwd | grep "^{{ User }}:"
           register: shell_result
           failed_when: shell_result.rc|int == 0 # Comment
       rescue: # Outputs more useful error
         - debug:
             msg:
             - "User: {{ User }} found in local password file ... assuming privileged account"
             - "Only a_radmin, or user accounts, allowed to run this micro-service"
           failed_when: shell_result.rc|int == 0

     - name: a_radmin set environment
       shell: |
         if [ -s ~andy/NOSUCH ]; then
           if [ ! -f ~andy/PROGRAMMING/yaml/.bashrc ]; then
             touch ~andy/PROGRAMMING/yaml/.bashrc
             echo "# Created to import tradingtech environment" >>~andy/PROGRAMMING/yaml/.bashrc
             chmod 644 ~andy/PROGRAMMING/yaml/.bashrc
           fi
           if [ ! -f ~andy/PROGRAMMING/yaml/.bashrc -o -z "`grep /tradingtech/bin/set_profile ~andy/PROGRAMMING/yaml/.bashrc`" ]; then
             echo "" >>~andy/PROGRAMMING/yaml/.bashrc
             echo "# Add MDS profile" >>~andy/PROGRAMMING/yaml/.bashrc
             echo "if [ -f /tradingtech/bin/set_profile ]; then" >>~andy/PROGRAMMING/yaml/.bashrc
             echo "	source /tradingtech/bin/set_profile" >>~andy/PROGRAMMING/yaml/.bashrc
             echo "fi" >>~andy/PROGRAMMING/yaml/.bashrc
           fi
         fi
       when: User == "a_radmin"
             


     - name: a_radmin task
       debug:
         msg: "Functional user: {{ User }}"
       when: User == "a_radmin"
       # Comment

     - name: SID task
       debug:
         msg: "User SID: {{ User }}"
       when: User != "a_radmin"


