我正在尝试运行一个简单的Ansible剧本,但不断收到以下错误,我不确定原因。
错误:注册不是Ansible Play的合法参数
以下是我尝试执行的代码
---
- name: Get SELinux sestatus
command: sestatus | grep enforcing | grep 'config file'
register: sestatus
- name: Check if module1.pp exists
stat:
path: bin/module1.pp
register: module1_pp
- name: Disable SELinux if enforcing
sudo: yes
command: "{{ item }}"
with_items:
- setenforce 0
- semodule -i bin/module1.pp
- setsebool -P httpd_can_network_connect 1
when: sestatus.rc == 0 and module1.stat.exists == true
答案 0 :(得分:1)
这是你的整本剧本?您错过了hosts
和tasks
声明。
- hosts: some_hosts
tasks:
- name: Get SELinux sestatus
command: sestatus | grep enforcing | grep 'config file'
register: sestatus
- name: Check if module1.pp exists
stat:
path: bin/module1.pp
register: module1_pp
- name: Disable SELinux if enforcing
sudo: yes
command: "{{ item }}"
with_items:
- setenforce 0
- semodule -i bin/module1.pp
- setsebool -P httpd_can_network_connect 1
when: sestatus.rc == 0 and module1.stat.exists == true