Command module does not accept setting environment variables inline
31 - disabled == false
32
33 - name: install ruby 2.3.1
34 command: CONFIGURE_OPTS='--disable-install-doc' rbenv install 2.3.135
36 - name: Take out of load balancer pool
37 local_action: ansible.builtin.command /usr/bin/take_out_of_pool {{ inventory_hostname }}
Description
Command module does not accept setting environment variables inline.
Use environment:
to set environment variables or use shell
module which accepts both.
Bad practice
- name: install ruby 2.3.1
command: CONFIGURE_OPTS='--disable-install-doc' RBENV_ROOT='{{ rbenv_root }}' rbenv install {{ rbenv_ruby_version }}
args:
creates: '{{ rbenv_root }}/versions/{{ rbenv_ruby_version }}/bin/ruby'
vars:
rbenv_root: /usr/local/rbenv
rbenv_ruby_version: 2.3.1
Recommended
---
- name: install ruby 2.3.1
command: rbenv install {{ rbenv_ruby_version }}
args:
creates: '{{ rbenv_root }}/versions/{{ rbenv_ruby_version }}/bin/ruby'
vars:
rbenv_root: /usr/local/rbenv
rbenv_ruby_version: 2.3.1
environment:
CONFIGURE_OPTS: '--disable-install-doc'
RBENV_ROOT: '{{ rbenv_root }}'
PATH: '{{ rbenv_root }}/bin:{{ rbenv_root }}/shims:{{ rbenv_plugins }}/ruby-build/bin:{{ ansible_env.PATH }}'