私は基本的にRedhatでもDebianでもリモートホストから動的情報を取得し、それに応じてOSのバージョンに従ってhttpパッケージをインストールする特定のファイルを実行したいと思います。
[root@ansi1 ansible]# cat include.yml
---
- hosts: all
tasks:
- name: Getting os info
include_vars: "{{ ansible_os_family }}.yml"
- include: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
[root@ansi1 ansible]#
[root@ansi1 ansible]#
[root@ansi1 ansible]#
[root@ansi1 ansible]# cat setup-RedHat.yml
---
- hosts: all
tasks:
- name: htttp install
yum: name=httpd state=present
アンサーブルプレイブックinclude.yml
間違い:
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/etc/ansible/setup-RedHat.yml': line 2, column 4, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: all
^ here
The error appears to have been in '/etc/ansible/setup-RedHat.yml': line 2, column 4, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- hosts: all
^ here
ベストアンサー1
include
セクションでこのモジュールを使用すると、tasks
プレイブックは含めることができず、タスクリストのみを含めることができます。つまり、ファイルにはsetup-RedHat.yml
次のコンテンツのみを含める必要があります。
- name: htttp install
yum: name=httpd state=present
- name: more tasks...