【发布时间】:2019-11-22 05:41:51
【问题描述】:
我正在尝试创建一个 Ansible 角色来在我的远程服务器上定义环境变量,但我的 linter 要求我使用“when:”语句来限制对命令模块的任何使用
- name: Set environment variables in .profile file
become: true
template:
src: .profile.j2
dest: "{{ env_home.value }}/.profile"
owner: "{{ unix_user.name }}"
group: "{{ unix_user.group }}"
mode: 0777
- name: Load environment variables from .profile file
become: true
become_user: "{{ unix_user.name }}"
command: "/bin/bash {{ env_home.value }}/.profile"
此代码返回已更改/确定,但我不知道环境变量是否在我的 .profile 模板中编写的export {{ env_home.variable }}={{ env_home.value }} 之后实际上定义得很好,我想添加一个任务检查所有环境变量是否都是在加载 .profile 之前定义与否
【问题讨论】:
标签: linux ansible environment-variables