How to run only one task in ansible playbook?

前端 未结 7 1077
一向
一向 2020-12-22 16:10

Is there a way to only run one task in ansible playbook?

For example, in roles/hadoop_primary/tasks/hadoop_master.yml. I have "start hadoop jo

相关标签:
7条回答
  • 2020-12-22 16:32

    This can be easily done using the tags

    The example of tags is defined below:

    ---
    hosts: localhost
    tasks:
     - name: Creating s3Bucket
       s3_bucket:
            name: ansiblebucket1234567890
       tags: 
           - createbucket
    
     - name: Simple PUT operation
       aws_s3:
           bucket: ansiblebucket1234567890
           object: /my/desired/key.txt
           src: /etc/ansible/myfile.txt
           mode: put
       tags:
          - putfile
    
     - name: Create an empty bucket
       aws_s3:
           bucket: ansiblebucket12345678901234
           mode: create
           permission: private
       tags:
           - emptybucket
    

    to execute the tags we use the command

    ansible-playbook creates3bucket.yml --tags "createbucket,putfile"
    
    0 讨论(0)
提交回复
热议问题