这是我到目前为止所拥有的:
- hosts: test
tasks:
- name: check existence of line in the target file to replace if there
command: grep fs.file-max /etc/sysctl.conf
changed_when: false
failed_when: false
register: file_test
- name: add config line to the file and reload
lineinfile:
path: /etc/sysctl.conf
line: fs.file-max = 65000
when: item.rc == 1
with_items:
- '{{ file_test.results }}'
command: sysctl -a
但是,它不断失败并出现以下问题:
The error appears to be in '/root/playbooks/sysctl.yml': line 8, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
register: file_test
- name: add config line to the file and reload
^ here
我已经尝试修复缩进并改变我这样做的方式,但我什么也没得到。