角色和剧本中的ansible标签

时间:2018-07-10 12:54:35

标签: ansible ansible-role

我有以下剧本,我正在尝试执行剧本时使用特定角色。但是在执行时,它将执行提到的所有三个角色,而不仅仅是标签。您能否建议在下面仅执行一个角色?使用标签?

 testplay.yml
  - name: copy file
    hosts: linuxdev01
    serial: 1
    vars_files:
      - "{{ instance }}/group_vars/dev1.yml"
    roles:
      - { role: dynamicapp, filename: stop, tags: ['stop'] }
      - { role: copyfile, filename: copy, tags: ['copy'] }
      - { role: dynamicapp,filename: start, tags: ['start'] }
    tags:
       - dev1

角色结构:

    roles/dynamicapp/tasks
 start.yml
     some tasks with no tags
 stop.yml
     some tasks with no tags
 main.yml
   -include: "{{ filename }}.yml"

执行:

 ansible-playbook ./testplay.yml --extra-vars '{"filename":"usersdata","instance":"staging"}' --tags "dev1,stop"

0 个答案:

没有答案