layout: true name: title_layout class: title_slide
layout: true name: section_layout class: section_slide
layout: true name: agenda_layout class: content_slide agenda_slide
layout: true name: thank_you class: thank_you
layout: true name: content_layout class: content_slide
template: title_layout
Daniel Mellado - Senior Software Engineer - Red Hat
Ansible Automates Zagreb, 11.12.2019
template: agenda_layout
- What's a Collection?
- Demo Time!
Slides available at: https://danielmellado.github.io/ansible_automates_zagreb
template: section_layout
What's a Collection?
- A new wat to distribute Ansible content
- An artifact format for consistent content structure
- Contains 1-N of roles, modules, plugins and module utilities
- Enables versioning of external content
- Enables consistent delivery independent of Ansible distributions
- Installable as system, user or project resources
- Immediate use of the content found within the artifact
- Namespacing support built into the collection
-
Difficult distribution of non-role content --
-
Plugin/role name collisions --
-
Difficult code-sharing for most plugins
-
Multiple roles with deps? Good luck.
-
Roles already distribute plugins- done?
- Requires role to be "entered" (see also ansible-wtf)
- Plugins are not "first-class citizens"
- Versioning/maintenance issues
-
Collection may contain 1-N:
- Roles/Modules/Plugins
- Playbooks (future/TBD)
-
Collection is the unit of distribution and versioning
-
Installable:
- globally
- per-user
- content-adjacent (ie per-project)
-
Default paths (searched in this order, configurable)
- (current playbook)/collections
- ~/.ansible/collections
- usr/share/ansible/collections
-
Mazer/ansible-galaxy
-
Content Hub
-
Ansible has a global(ish) flat plugin namespace
-
Role1 and Role2 both distribute my_module
- Which one will get used? (ha!)
- Can I use them both in the same run? (no
- What if core later includes a my_module? (screwed)
- What if the project has in library/ ?
- What if the user has in ~/.ansible/?
- What if the system has in /usr/share/ansible ?
- Issue exists for roles and all modules/plugins
-
Collections have a namespace and name
- For distribution, namespace == Galaxy user/org
-
Content in collections is accessed by namespace
- mynamespace.mycollection.my_module
- f5.bigip.provisioning_role
-
Built-in collections
- ansible.builtin
- ansible.legacy
- hosts: somehosts
tasks:
- myns.mycollection.athing:
- ansible.builtin.ping: # use only the ping packaged in core
- ansible.legacy.ping: # use core or library(etc)/ping.py
when: thing | myns.mycollection.filter == 42
- ping: # still works, == ansible.legacy.ping:
template: section_layout
That's awfully verbose
- hosts: somehosts
collections:
- ansible.builtin
- myns.mycollection
- otherns.othercollection
tasks:
- mymodule: # first found in the list of collections
- otherns.othercollection.mymodule: # fully-qualified is fine
- module_utils only works for modules
- unless you're "in the box"
- perverse incentives
- eg, Azure/AWS want to share utility code between
- modules/actions/inventory/lookup plugins
- Just use pip!
- Entire collection is a Python namespace package
- All installed collection content is accessible
- even across collections!
ansible_collections
root Python namespaceansible_collections.mynamespace.mycollection
template: section_layout
Demo time!
template: section_layout
.medium-text[ Slides are available on
http://creativecommons.org/licenses/by/4.0/ ]
template: thank_you
Slides can be found at:
Daniel Mellado
[email protected] dmellado (freenode)
</textarea>
<script src="remark.js" type="text/javascript"></script>
<script type="text/javascript">
var slideshow = remark.create({
ratio: '16:9',
slideNumberFormat: '%current% <span class="designator">Ansible Automates Zagreb - Collections · December 2019</span>',
countIncrementalSlides: false
});
</script>