Ansible 剧本中的角色和任务
我的ansible playbook与下面的代码类似:Ansible 剧本中的角色和任务,ansible,Ansible,我的ansible playbook与下面的代码类似: --- - hosts: localhost connection: local tasks: - name: "Create custom fact directory file: path: "/etc/ansible/facts.d" state: "directory" - name: "Insert custom fact file" copy: src: custom_fact
---
- hosts: localhost
connection: local
tasks:
- name: "Create custom fact directory
file:
path: "/etc/ansible/facts.d"
state: "directory"
- name: "Insert custom fact file"
copy:
src: custom_fact.fact
dest: /etc/ansible/facts.d/custom_fact.fact
mode: 0755
roles:
- role1
- role2
一旦我使用ansible playbook命令运行playbook
只有角色正在运行,但任务没有运行
如果我对剧本中的角色进行注释,任务就会运行
如何使任务在角色之前运行?将任务放在“在角色之前运行的任务”部分中
您还可能发现post_任务非常有用,它在角色之后运行任务 纠正压痕
- hosts: localhost
connection: local
tasks:
- name: "Create custom fact directory
file:
path: ...