There’s quite a bit about this topic in the documentation:
The main difference is:
All
import*
statements are pre-processed at the time playbooks are parsed.
Allinclude*
statements are processed as they encountered during the execution of the playbook.
So import
is static, include
is dynamic.
From my experience, you should use import
when you deal with logical “units”. For example, separate long list of tasks into subtask files:
main.yml:
- import_tasks: prepare_filesystem.yml
- import_tasks: install_prerequisites.yml
- import_tasks: install_application.yml
But you would use include
to deal with different workflows and take decisions based on some dynamically gathered facts:
install_prerequisites:
- include_tasks: prerequisites_{{ ansible_os_family | lower }}.yml
Related Posts:
- Missing sudo password in Ansible
- How to see stdout of ansible commands?
- How to set default Ansible username/password for SSH connection?
- Ansible: Execute task only when a tag is specified
- Adding a user to an additional group using ansible
- How to unify package installation tasks in ansible?
- Why am I getting error for apple-touch-icon-precomposed.png
- How could I ping @here in Discord.py?
- What’s the syntax for mod in java
- STDERR? What is it? What are its common uses?
- Handling file renames in Git
- PermissionError: [Errno 13] in Python
- Why are there two ways to unstage a file in Git?
- ‘git’ is not recognized as an internal or external command
- How to link to part of the same document in Markdown?
- What is {{.}} in mustache?
- How to split column into two in R using separate
- Python Key Error=0 – Can’t find Dict error in code
- What is a callback URL in relation to an API?
- DynamoDB : The provided key element does not match the schema
- How do I run a single test using Jest?
- Why I am getting java.lang.AbstractMethodError errors?
- Mercurial: no ~/.hgrc file
- How to create a directory using Ansible
- PHP &$string – What does this mean?
- difference between ‘-webkit-box-shadow’ & ‘box-shadow’ in css
- Operand type clash: int is incompatible with date + The INSERT statement conflicted with the FOREIGN KEY constraint
- org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect’ not set
- java.io.IOException: Broken pipe
- java.util.NoSuchElementException: No line found
- Update Git branches from master
- declaring a priority_queue in c++ with a custom comparator
- How to interactively (visually) resolve conflicts in SourceTree / git
- How to get the selected item from a ComboBox in JavaFX?
- Downcasting in Java
- How do I get monitor resolution in Python?
- SQL array flattening: Why doesn’t CROSS JOIN UNNEST join every nested value with every row?
- Function to calculate R2 (R-squared) in R
- SonarQube Runner vs Scanner
- How to ‘minify’ Javascript code
- How to extract Month from date in R
- Receiving “message”:”CB-ACCESS-KEY header is required” when attempting to connect to coinbase pro api
- Missing files, DirectX SDK (d3dx9.lib, d3dx9.h)
- how to center form using bootstrap 4
- How to implement OnFragmentInteractionListener
- Error haskell: not in scope. What does that mean?
- Fail to create Android virtual Device, “No system image installed for this Target”
- How do I select text nodes with jQuery?
- In Java, what is a shallow copy?
- conversion to inaccessible base class is not allowed [duplicate]
- A difference between statement and decision coverage
- How to draw a line with matplotlib?
- Android marshmallow : Galaxy Note 4 Screen Overlay Detected
- Get all object attributes in Python?
- Example of realpath function in C
- Printing a 2D array in C
- wp_localize_script with mce_external_plugins in wordpress
- Send an email that contains a HTML and plain text part
- Filtering the Comment Form Allowed Tags
- Contact Form 7: Redirecting on a condition? [closed]
- Deleting images in array
- How do I display the latest Flickr OAuth embedded image on the frontpage?
- Next Previous siblings child pages
- dbDelta with the character ;
- Posts2Posts plugin and wp user frontend connect programmatically
- Is there function similar to wp_upload_bits() that will allow uploading to a specific path?
- Limiting the posts on the homepage to one taxonomy? [closed]
- Need a method for base_url() or home_url() in CF7 additional settings [closed]
- Pulling Individual Posts from WP_Query
- How to check, if user commented before, on comment_post action?
- add_image_size sizes not stored
- parsererror | SyntaxError: Unexpected token < in JSON at position 0
- 100% uptime for a web application
- How to assign permissions to ApplicationPoolIdentity account
- Is it bad to redirect http to https?
- Using DD for disk cloning
- What tool do you use to monitor your servers?
- Sudo as different user and running screen
- What is the difference between Load Balancer and Reverse Proxy?
- Should servers be turned off at night?
- Where to check log of sendmail?
- How can I see Time-To-Live (TTL) for a DNS record?
- Rsync difference between –checksum and –ignore-times options
- What is a good SSH server to use on Windows? [closed]
- In systemd, what’s the difference between After= and Requires=?
- Windows Server restart / shutdown history
- How do I set the global PATH environment variable on OS X?
- nmap find all alive hostnames and IPs in LAN
- Should CNAME Be Used For Subdomains?
- How do I create user accounts from the Terminal in Mac OS X 10.5?
- How to get a .pem file from ssh key pair?
- How to inspect remote SMTP server’s TLS certificate?
- Choosing between meaningful and meaningless hostnames [closed]
- logrotating files in a directories and its subdirectories
- Multiple TXT fields for same subdomain
- How to restart Nginx on Mac OS X?
- Do SPF Records For Primary Domain apply to subdomains?
- Why is the response on localhost so slow?
- apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName