"Remediating" 使用 Ansible 的状态,当配置文件中存在错误并且未安装包时
"Remediating" state with Ansible, when there is an error in config file AND package is not installed
我的 Ansible 角色强制执行所需的状态。如果未安装 smokeping,and/or 我的 Targets
未在 smokeping 中配置,它将更正此问题。 (我在这里简化了角色)。
- name: Install smokeping
package:
name:
- smokeping
state: present
- name: Configure smokeping Alerts
copy:
src: Alerts
dest: /etc/smokeping/config.d/
notify:
- Reload smokeping
除此之外,如果警报中存在错误且吸烟已被删除,它将无法工作。在这种情况下,smokeping 将无法安装。这个案子也能解决吗?
Unpacking smokeping (2.7.3-2) ...
Setting up smokeping (2.7.3-2) ...
apache2_invoke cgi: already enabled
apache2_invoke: Enable configuration smokeping
Job for smokeping.service failed because the control process exited with error code.
See "systemctl status smokeping.service" and "journalctl -xe" for details.
invoke-rc.d: initscript smokeping, action "restart" failed.
● smokeping.service - Latency Logging and Graphing System
Loaded: loaded (/lib/systemd/system/smokeping.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-02-28 16:19:01 GMT; 11ms ago
Docs: man:smokeping(1)
file:/usr/share/doc/smokeping/examples/systemd/slave_mode.conf
Process: 7227 ExecStart=/usr/sbin/smokeping --pid-dir=/run/smokeping (code=exited, status=25)
Feb 28 16:19:00 silo systemd[1]: Starting Latency Logging and Graphing System...
Feb 28 16:19:01 silo smokeping[7227]: ERROR: /etc/smokeping/config.d/Alerts, line 2: put an email address or the name of a program here
Feb 28 16:19:01 silo systemd[1]: smokeping.service: Control process exited, code=exited, status=25/n/a
Feb 28 16:19:01 silo systemd[1]: smokeping.service: Failed with result 'exit-code'.
Feb 28 16:19:01 silo systemd[1]: Failed to start Latency Logging and Graphing System.
dpkg: error processing package smokeping (--configure):
installed smokeping package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u6) ...
Errors were encountered while processing:
smokeping
E: Sub-process /usr/bin/dpkg returned an error code (1)
是的。先写配置文件,再安装smokeping。
如果您的配置包含机密,您需要小心权限。 (也许先创建用户和组 smokeping
?)
在安装 smokeping 之前,我们在第一个任务中有 notify: Reload smokeping
不是问题。处理程序 运行 最后,在所有任务之后 运行.
我的 Ansible 角色强制执行所需的状态。如果未安装 smokeping,and/or 我的 Targets
未在 smokeping 中配置,它将更正此问题。 (我在这里简化了角色)。
- name: Install smokeping
package:
name:
- smokeping
state: present
- name: Configure smokeping Alerts
copy:
src: Alerts
dest: /etc/smokeping/config.d/
notify:
- Reload smokeping
除此之外,如果警报中存在错误且吸烟已被删除,它将无法工作。在这种情况下,smokeping 将无法安装。这个案子也能解决吗?
Unpacking smokeping (2.7.3-2) ...
Setting up smokeping (2.7.3-2) ...
apache2_invoke cgi: already enabled
apache2_invoke: Enable configuration smokeping
Job for smokeping.service failed because the control process exited with error code.
See "systemctl status smokeping.service" and "journalctl -xe" for details.
invoke-rc.d: initscript smokeping, action "restart" failed.
● smokeping.service - Latency Logging and Graphing System
Loaded: loaded (/lib/systemd/system/smokeping.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2021-02-28 16:19:01 GMT; 11ms ago
Docs: man:smokeping(1)
file:/usr/share/doc/smokeping/examples/systemd/slave_mode.conf
Process: 7227 ExecStart=/usr/sbin/smokeping --pid-dir=/run/smokeping (code=exited, status=25)
Feb 28 16:19:00 silo systemd[1]: Starting Latency Logging and Graphing System...
Feb 28 16:19:01 silo smokeping[7227]: ERROR: /etc/smokeping/config.d/Alerts, line 2: put an email address or the name of a program here
Feb 28 16:19:01 silo systemd[1]: smokeping.service: Control process exited, code=exited, status=25/n/a
Feb 28 16:19:01 silo systemd[1]: smokeping.service: Failed with result 'exit-code'.
Feb 28 16:19:01 silo systemd[1]: Failed to start Latency Logging and Graphing System.
dpkg: error processing package smokeping (--configure):
installed smokeping package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u6) ...
Errors were encountered while processing:
smokeping
E: Sub-process /usr/bin/dpkg returned an error code (1)
是的。先写配置文件,再安装smokeping。
如果您的配置包含机密,您需要小心权限。 (也许先创建用户和组 smokeping
?)
在安装 smokeping 之前,我们在第一个任务中有 notify: Reload smokeping
不是问题。处理程序 运行 最后,在所有任务之后 运行.