1

运行我的脚本时,我不断收到“错误!字段‘主机’是必需的,但未设置”。谁能告诉我我错过了什么。我目前正在尝试在 2 个 centos 6 虚拟机上实施 DISA stig 强化。

---
- name: Stig implementation
  hosts: Database
  tasks:


  - name: upgrade all packages
    command: yum upgrade -y

  - name: update all packages
    command: yum update -y

  - name: /etc/passd file is owned by root
    command: chown root:root /etc/passwd

  - name: remove rsh-server package
    command: yum erase rsh-server

  - name: bootload configuration owner is root
    command: chgrp root /etc/grub.conf

  - name: rshd service disabled
    command: chkconfig rsh off

  - name: rexecd service disabled
    command: chkconfig rexec off

  - name: remove telnet and telnet-server
    command: yum erase telnet-server && yum erase telnet

  - lineinfile: dest=/etc/ssh/sshd_config
               state=present
               regexp='PermitEmptyPasswords'
               line='PermitEmptyPasswords no'
               backup=yes

  - lineinfile: dest=/etc/ssh/sshd_config
               state=present
               regexp='HostbasedAuthentication'
               line='HostbasedAuthentication no'
               backup=yes

  - name: Change etc/group ownership
    command: chgrp root /etc/group

  - name: operating system must connect to external networks
    command:  chkconfig ip6tables on && service ip6tables start

  - name: add lines
    lineinfile: dest=/etc/audit/audit.rules
               line='{{item}}'
    with_items:
      - '-w /sbin/insmod -p x -k modules'
      - '-w /sbin/rmmod -p x -k modules'
      - '-w /sbin/modprobe -p x -k modules'
      - '-a always,exit -F arch=[b64] -S init_module -S delete_module -k modules'

  - name: disable xinetd
    command: chkconfig xinetd off && service xinetd stop

  - name: turn off and disable netconsole
    command: chkconfig netconsole off && service netconsole stop

我的主机文件的副本

[localhost]
x.x.x.x
[Database]
x.x.x.x
x.x.x.x
4

1 回答 1

0

我想这是一本剧本...您可以尝试删除第二行吗:

---
- hosts: Database
  tasks:
  ...
于 2016-07-12T23:38:09.780 回答