How do I detect an existing interactive console from inside ansible? -
i want change behaviour of ansible playbook when executed within interactive console opposed non-interactive console (like ci environment)
how can inside playbook?
you need way determine whether command runs ci or not. if have access command run suggest add variables command, example
ansible-playbook -i inv.yml --extra-vars "ci=true" playbook.yml
and can refer ci
variable inside playbook determine do.
if cumbersome best thing rely on environmental variables ci servers set. should consult documentation of ci server whether sets kind of environmental variables, , if yes do. (but not all) set ci
variable true
. worst case scenario should specify variable manually in configuration of ci server.
you should able access environment variables of management host machine using:
{{ lookup('env','ci') }}
of course these options work have make sure environment variable set on non-interactive shells (which ci should you), , not set on interactive ones.
Comments
Post a Comment