【发布时间】:2022-10-14 22:19:44
【问题描述】:
我有一个简单的 ansible 剧本,它设置了两个 ini 变量。
- name: set Apache timeout
community.general.ini_file:
path: /etc/apache2/apache2.conf
section: null
option: Timeout
value: 900
state: present
exclusive: true
- name: set Proxy timeout
community.general.ini_file:
path: /etc/apache2/apache2.conf
section: null
option: ProxyTimeout
value: 900
state: present
exclusive: true
问题是它让他们喜欢
Timeout = 900
ProxyTimeout = 900
但我需要将它们设置为,没有“=”
Timeout 900
ProxyTimeout 900
编辑这解决了它。
- name: set Timeout
ansible.builtin.lineinfile:
path: /etc/apache2/apache2.conf
regexp: '^Timeout '
insertafter: '^#Timeout '
line: Timeout 900
- name: set Proxy timeout
ansible.builtin.lineinfile:
path: /etc/apache2/apache2.conf
regexp: '^ProxyTimeout '
insertafter: '^Timeout '
line: ProxyTimeout 900
【问题讨论】:
-
apache2.conf不是 ini 格式,因此您没有使用正确的模块来满足您的要求。
-
你知道用于 conf 文件的模块吗?
标签: ansible ansible-2.x