ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误

这篇具有很好参考价值的文章主要介绍了ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在我的剧本中,我有一个更新 audit.rules 的任务,然后通知应该重新启动 auditd 服务的处理程序。

task:
  - name:  6.6.7 - audit rules configuration
    template: src=X/ansible/templates/auditd_rules.j2
              dest=/etc/audit/rules.d/audit.rules
              backup=yes
              owner=root group=root mode=0640
     notify:
   - restart auditd


  handlers:
    - name: restart auditd
      service: name=auditd state=restarted

当 playbook 运行时,会更新审计规则并请求重新启动 auditd,但这会失败,如下所示。
RUNNING HANDLER [restart auditd] *********************************************** fatal: [ipX-southeast-2.compute.internal]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to restart service auditd: Failed to restart auditd.service: Operation refused, unit auditd.service may be requested by dependency only.\n"} 

当我查看auditd 的单元定义时,我可以看到rejectManualStop=yes。这就是我无法重新启动服务的原因吗?一个人如何来接受新的审计规则?
 systemctl cat auditd.service
# /usr/lib/systemd/system/auditd.service
[Unit]
Description=Security Auditing Service
DefaultDependencies=no
After=local-fs.target systemd-tmpfiles-setup.service
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
RefuseManualStop=yes
ConditionKernelCommandLine=!audit=0
Documentation=man:auditd(8) https://people.redhat.com/sgrubb/audit/

[Service]
ExecStart=/sbin/auditd -n
## To not use augenrules, copy this file to /etc/systemd/system/auditd.service
## and comment/delete the next line and uncomment the auditctl line.
## NOTE: augenrules expect any rules to be added to /etc/audit/rules.d/
ExecStartPost=-/sbin/augenrules --load
#ExecStartPost=-/sbin/auditctl -R /etc/audit/audit.rules
ExecReload=/bin/kill -HUP $MAINPID
# By default we don't clear the rules on exit. To enable this, uncomment
# the next line after copying the file to /etc/systemd/system/auditd.service
#ExecStopPost=/sbin/auditctl -R /etc/audit/audit-stop.rules

[Install]
WantedBy=multi-user.target

最佳答案

这已在 Red Hat Bugzilla #1026648 中进行了探索、讨论和解决(大部分)。和 Anisble Issue # 22171 (github)报告。

分辨率

  • 使用 ansible service模块参数use=service强制执行 /sbin/service实用程序而不是 systemd 的聚集事实值(调用 /sbin/systemctl )像这样:
  • - service: name=auditd state=restarted use=service
  • Example playbook (pastebin.com)
  • 解决方法:
  • 使用 ansible command模块来显式运行服务可执行文件,如下所示:
  • - command: /sbin/service auditd restart
  • 分析——根本原因:
     
    • This is an issue created by upstream packaging of auditd.service unit. It will not start/stop/restart when acted upon by systemctl, apparently by design.
    • It is further compounded by the Ansible service control function, which uses the preferred method identified when system facts are gathered and "ansible_service_mgr" returns "systemd". This is regardless of the actual module used to manage the service.unit.
    • RHEL dev team may fix if considered a problem in upcoming updates (ERRATA)
    • Ansible dev team has offered a workaround and (as of 2.2) updated the service module with the use parameter.

关于ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误,我们在Stack Overflow上找到一个类似的问题: centos7 - ansible: how to restart auditd service on centos 7 get error about dependency - Stack Overflow

在我的剧本中,我有一个更新 audit.rules 的任务,然后通知应该重新启动 auditd 服务的处理程序。

task:
  - name:  6.6.7 - audit rules configuration
    template: src=X/ansible/templates/auditd_rules.j2
              dest=/etc/audit/rules.d/audit.rules
              backup=yes
              owner=root group=root mode=0640
     notify:
   - restart auditd


  handlers:
    - name: restart auditd
      service: name=auditd state=restarted

当 playbook 运行时,会更新审计规则并请求重新启动 auditd,但这会失败,如下所示。
RUNNING HANDLER [restart auditd] *********************************************** fatal: [ipX-southeast-2.compute.internal]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to restart service auditd: Failed to restart auditd.service: Operation refused, unit auditd.service may be requested by dependency only.\n"} 

当我查看auditd 的单元定义时,我可以看到rejectManualStop=yes。这就是我无法重新启动服务的原因吗?一个人如何来接受新的审计规则?
 systemctl cat auditd.service
# /usr/lib/systemd/system/auditd.service
[Unit]
Description=Security Auditing Service
DefaultDependencies=no
After=local-fs.target systemd-tmpfiles-setup.service
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
RefuseManualStop=yes
ConditionKernelCommandLine=!audit=0
Documentation=man:auditd(8) https://people.redhat.com/sgrubb/audit/

[Service]
ExecStart=/sbin/auditd -n
## To not use augenrules, copy this file to /etc/systemd/system/auditd.service
## and comment/delete the next line and uncomment the auditctl line.
## NOTE: augenrules expect any rules to be added to /etc/audit/rules.d/
ExecStartPost=-/sbin/augenrules --load
#ExecStartPost=-/sbin/auditctl -R /etc/audit/audit.rules
ExecReload=/bin/kill -HUP $MAINPID
# By default we don't clear the rules on exit. To enable this, uncomment
# the next line after copying the file to /etc/systemd/system/auditd.service
#ExecStopPost=/sbin/auditctl -R /etc/audit/audit-stop.rules

[Install]
WantedBy=multi-user.target

最佳答案

这已在 Red Hat Bugzilla #1026648 中进行了探索、讨论和解决(大部分)。和 Anisble Issue # 22171 (github)报告。

分辨率

  • 使用 ansible service模块参数use=service强制执行 /sbin/service实用程序而不是 systemd 的聚集事实值(调用 /sbin/systemctl )像这样:
  • - service: name=auditd state=restarted use=service
  • Example playbook (pastebin.com)
  • 解决方法:
  • 使用 ansible command模块来显式运行服务可执行文件,如下所示:
  • - command: /sbin/service auditd restart
  • 分析——根本原因:
     
    • This is an issue created by upstream packaging of auditd.service unit. It will not start/stop/restart when acted upon by systemctl, apparently by design.
    • It is further compounded by the Ansible service control function, which uses the preferred method identified when system facts are gathered and "ansible_service_mgr" returns "systemd". This is regardless of the actual module used to manage the service.unit.
    • RHEL dev team may fix if considered a problem in upcoming updates (ERRATA)
    • Ansible dev team has offered a workaround and (as of 2.2) updated the service module with the use parameter.

关于ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误,我们在Stack Overflow上找到一个类似的问题: centos7 - ansible: how to restart auditd service on centos 7 get error about dependency - Stack Overflow

在我的剧本中,我有一个更新 audit.rules 的任务,然后通知应该重新启动 auditd 服务的处理程序。

task:
  - name:  6.6.7 - audit rules configuration
    template: src=X/ansible/templates/auditd_rules.j2
              dest=/etc/audit/rules.d/audit.rules
              backup=yes
              owner=root group=root mode=0640
     notify:
   - restart auditd


  handlers:
    - name: restart auditd
      service: name=auditd state=restarted

当 playbook 运行时,会更新审计规则并请求重新启动 auditd,但这会失败,如下所示。
RUNNING HANDLER [restart auditd] *********************************************** fatal: [ipX-southeast-2.compute.internal]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to restart service auditd: Failed to restart auditd.service: Operation refused, unit auditd.service may be requested by dependency only.\n"} 

当我查看auditd 的单元定义时,我可以看到RejectManualStop=yes。这就是我无法重新启动服务的原因吗?一个人如何来接受新的审计规则?
 systemctl cat auditd.service
# /usr/lib/systemd/system/auditd.service
[Unit]
Description=Security Auditing Service
DefaultDependencies=no
After=local-fs.target systemd-tmpfiles-setup.service
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
RefuseManualStop=yes
ConditionKernelCommandLine=!audit=0
Documentation=man:auditd(8) https://people.redhat.com/sgrubb/audit/[Service]
ExecStart=/sbin/auditd -n
## To not use augenrules, copy this file to /etc/systemd/system/auditd.service
## and comment/delete the next line and uncomment the auditctl line.
## NOTE: augenrules expect any rules to be added to /etc/audit/rules.d/
ExecStartPost=-/sbin/augenrules --load
#ExecStartPost=-/sbin/auditctl -R /etc/audit/audit.rules
ExecReload=/bin/kill -HUP $MAINPID
# By default we don't clear the rules on exit. To enable this, uncomment
# the next line after copying the file to /etc/systemd/system/auditd.service
#ExecStopPost=/sbin/auditctl -R /etc/audit/audit-stop.rules

[Install]
WantedBy=multi-user.target

最佳答案

这已在 Red Hat Bugzilla #1026648 中进行了探索、讨论和解决(大部分)。和 Anisble Issue # 22171 (github)报告。

分析:

  • 使用 ansible service模块参数use=service强制执行 /sbin/service实用程序而不是 systemd 的聚集事实值(调用 /sbin/systemctl )像这样:
- service: name=auditd state=restarted use=service
  • Example playbook (pastebin.com)
  • 解决方法:
  • 使用 ansible command模块来显式运行服务可执行文件,如下所示:
- command: /sbin/service auditd restart

分析——根本原因:
 

  • This is an issue created by upstream packaging of auditd.service unit. It will not start/stop/restart when acted upon by systemctl, apparently by design.
  • It is further compounded by the Ansible service control function, which uses the preferred method identified when system facts are gathered and "ansible_service_mgr" returns "systemd". This is regardless of the actual module used to manage the service.unit.
  • RHEL dev team may fix if considered a problem in upcoming updates (ERRATA)
  • Ansible dev team has offered a workaround and (as of 2.2) updated the service module with the use parameter.

关于ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误,我们在Stack Overflow上找到一个类似的问题: centos7 - ansible: how to restart auditd service on centos 7 get error about dependency - Stack Overflow

https://stackoverflow.com/questions/41053331/

ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误,ansible,centos,linux

ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误,ansible,centos,linux

简单来说就是auditd开发者觉着auditd是系统底层记录日志的服务,不应由管理员重启或停止其服务。

解决方法:

1、使用service auditd restart可以绕过systemctl重启auditd服务。

2、修改systemd服务配置文件/usr/lib/systemd/system/auditd.service配置RefuseManualStop=No,执行systemctl deamon-reload。后可以使用systemctl restart auditd

在ansible-play里,1、可以使用command模块代替service模块,重启auditd服务。

- command: /sbin/service auditd restart

或者2、修改auditd.service配置文件,使systemctl可以管理auditd文章来源地址https://www.toymoban.com/news/detail-782985.html

到了这里,关于ansible:如何在centos 7上重新启动auditd服务得到关于依赖的错误的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 重新启动Linux服务器中的 ES

    ES不支持直接重启,只能先结束掉进程,再运行脚本重启。 下面是操作的过程: 1、先查找出服务器的ES进程,可以用以下两个命令进行查找: 紧跟指令 jintaiyang+  的 15870就是我们需要查找的ES 服务进程 pid 2、结束ES进程 kill -9 pid(进程号,此处是15870) 3、重新启动ES ( 注意:

    2024年02月05日
    浏览(30)
  • VSCode报错,语言服务器崩溃。正在重新启动...

    连接Linux服务器时,Vscode写C++时报错如题,或者 [Error - 2:26:24 PM] Sending request cpptools/getSemanticTokens failed. Message: Pending response rejected since connection got disposed Code: -32097 [Error - 2:26:24 PM] Sending request cpptools/getInlayHints failed. Message: Pending response rejected since connection got disposed Code: -32097 [

    2024年02月08日
    浏览(81)
  • 如何在 Ubuntu 操作系统上重新启动 Nginx?

    Nginx 是一个常用的开源的高性能 Web 服务器和反向代理服务器。在使用 Nginx 时,有时需要重新启动该服务,以应用配置更改或解决某些问题。本文将详细介绍在 Ubuntu 操作系统上重新启动 Nginx 的不同方法和技巧。 systemctl 命令是在 Ubuntu 上管理系统服务的标准工具。要重新启动

    2024年02月07日
    浏览(38)
  • centos linux中使用docker关于nacos启动异常

    nacos启动出现异常: Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :No DataSource set 在docker中启动nacos发先启动异常可以先查询docker中的镜像 docker images查询所有的镜像有nacos的          使用docker ps -a查询容器的

    2024年02月11日
    浏览(38)
  • 如何重新启动k8s集群,并查看的状态

    重新启动k8s集群的方法取决于您使用的部署方式。 如果您使用的是kubeadm部署,可以使用以下命令重启集群: 如果您使用的是其他部署工具,请按照该工具的说明操作。 查看集群状态可以使用kubectl命令,如: 该命令会列出集群中所有节点的状态。 该命令会列出集群中所有命名

    2024年02月11日
    浏览(32)
  • 如何使用命令提示符重新启动Windows 资源管理器?

    电脑资源管理器出现问题,导致电脑黑屏,如何使用命令提示符重新启动Windows 资源管理器呢?出现这个问题的时候,不要慌,按照下面的操作步骤,大概率是可以复原的,当然你觉得这样比较麻烦,也可以直接重启电脑解决这个问题,以下步骤方法是针对不重启电脑的解决

    2024年02月11日
    浏览(30)
  • 关于安装win10系统的时候出现的提示,使用其他标明64位的安装光盘。在插入光盘时,将自动重新启动windows安装程序的解决办法。

    更换win10镜像文件,下载就好,win10 下载地址:https://next.itellyou.cn/Original/#cbp=Product?ID=f905b2d9-11e7-4ee3-8b52-407a8befe8d1

    2024年02月11日
    浏览(46)
  • linux 如何查看es进程,Linux---关闭Elasticsearch进程,并重新启动

    查看ES进程: 执行命令:ps -ef | grep elasticsearch 如果有elasticsearch进程,则会返回包含elasticsearch的进程信息,如下所示: 如果没有elasticsearch进程,则不会返回任何信息。 关闭ES进程: 执行命令:sudo systemctl stop elasticsearch 等待一段时间,直到ES进程完全停止。 重新启动

    2024年02月11日
    浏览(36)
  • 【uniapp关联unicloud,阿里云云服务空间】unicloud本地调试服务启动失败:当前项目未关联unicloud服务空间,请调整后重新运行,已解决

    最近开发app项目,很多都是第一次上手 1、在Hbuider中运行项目,出现如下提示 2、项目根目录下已有uniCloud文件夹 3、如果云开发环境未创建,可以右击项目,选择创建uniCloud云开发环境 4、创建好的目录如下,index.js中是getPhoneNumber,uniapp调用一键登录时需要用到 5、右击uniCl

    2024年02月08日
    浏览(38)
  • 【报Bug】同步资源失败,未得到同步资源的授权,请停止运行后重新运行,并注意手机上的授权提示

    bug截图   场景描述 一开始正常编译运行,由于我觉得应用页面有些许奇怪的bug,边想着卸载,重新运行安装调试基座。卸载后,运行还是会出现 ,明明我已经把应用卸载了,还是会出现这种情况,后来各种百度红色字体的报错,没有寻得能够解决的方案。   解决方式 我还

    2024年02月13日
    浏览(26)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包