我有一个简单的 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
答案1
如果有人好奇的话,这是有效的
- 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