can roles and tasks exist in the same playbook?

后端 未结 4 1976
囚心锁ツ
囚心锁ツ 2021-02-12 12:48
---
# file: main.yml

- hosts: fotk
  remote_user: fakesudo
  tasks:
  - name: create a developer user
    user: name={{ user }}
          password={{ password }}
               


        
4条回答
  •  别那么骄傲
    2021-02-12 13:04

    https://docs.ansible.com/playbooks_roles.html#roles

    If the play still has a ‘tasks’ section, those tasks are executed after roles are applied.

    If you wish to run tasks before or after roles are executed, you need to list these under pre_tasks and post_tasks. Thus, there is no way to run "loose" tasks between two roles. You might want to create a dedicated role for these tasks.

提交回复
热议问题