Problem setting up the bash environment with playbook.

I am trying to execute the commands over playbook.

  • name: Configure open-pbis
    action: command /opt/pbis/bin/config LoginShellTemplate /bin/bash
    action: command /opt/pbis/bin/config AssumeDefaultDomain true

It is not setting the bash environment when I execute it with anisble-playbook.

[root@xxxxxxxxx~]# su - yyyy
-sh-4.1$ env|grep SHELL
SHELL=/bin/sh
-sh-4.1$

Whereas, it is working absolutely fine when I execute the command " /opt/pbis/bin/config LoginShellTemplate /bin/bash"

[yyyyy@xxxxxxxxxxxxxxxxxxxx ~]$ env|grep SHELL
SHELL=/bin/bash

Is there any thing special I have to do to make sure the command is executed as it is, it should reflect the bash as SHELL.

Thanks

It worked after I moved the command to another task section

  • name: Configure open-pbis login shell
    command: ‘/opt/pbis/bin/config LoginShellTemplate /bin/bash’
  • name: Configure open-pbis default domain
    command: /opt/pbis/bin/config AssumeDefaultDomain true

Can I cascade commands one after the other after from one section ?

Ansible doesn’t use the host environment files like .bashrc because it’s inconsistent if you have many hosts, it encourages centralized management.

To set environment variables, see this feature:

http://docs.ansible.com/playbooks_environment.html