注册不是Ansible Play

时间:2017-08-14 17:39:27

标签: ansible conditional-statements

我正在尝试运行一个简单的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

1 个答案:

答案 0 :(得分:1)

这是你的整本剧本?您错过了hoststasks声明。

- 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