Andy_Smith  
                
                  
                    November 29, 2018,  5:21am
                   
                  1 
               
             
            
              Hi,
Is there a way to apply a tag to all of the import_tasks statements
That is, given a directory structure a bit like this:
.
site.yml:
- hosts: all
And roles/some_server/tasks/main.yml:
- import_tasks: configure_this.yml
If I tried to conditionally apply only tag "some_server" then it
If I add a tag attribute to each of those imports, i.e.:
- import_tasks: configure_this.yml tags=some_server
then that works as the tasks within each of those imported files do
Is there a nice way to say that "every following import_tasks should
Thanks,
             
            
              
            
           
          
            
            
              
Is there a way to apply a tag to all of the import_tasks statements
That is, given a directory structure a bit like this:
.
site.yml:
- hosts: all
 
That's what you're do here, add tag some_server on all task in the role role_server.
    - {
 
And this will add tag other_role on all tasks in the role.
And roles/some_server/tasks/main.yml:
- import_tasks: configure_this.yml
If I tried to conditionally apply only tag "some_server" then it
If I add a tag attribute to each of those imports, i.e.:
- import_tasks: configure_this.yml tags=some_server
 
Since you are setting the tag on the role in the play, you don't need to tag it here again.
             
            
              
            
           
          
            
              
                Andy_Smith  
              
                  
                    November 29, 2018,  6:41am
                   
                  3 
               
             
            
              Hi Kai,
>If I add a tag attribute to each of those imports, i.e.:
Since you are setting the tag on the role in the play, you don't need to tag
 
If I leave out the "tags=some_server" and then do:
$ ansible-playbook --tags some_server
none of the imported tasks are executed (or maybe not even
If I add "tags=some_server" on the end of them, then they are.
This is with Ansible version 2.5.1.
Cheers,
             
            
              
            
           
          
            
              
                system  
              
                  
                    November 30, 2018,  2:51pm
                   
                  5 
               
             
            
              import tasks does not allow for 'inline keywords', you need to set
- import_tasks: other_config.yml