Class: AutomateIt::TagManager
- Inherits:
-
Plugin::Manager
- Object
- Common
- Plugin::Base
- Plugin::Manager
- AutomateIt::TagManager
- Defined in:
- lib/automateit/tag_manager.rb
Overview
TagManager
The TagManager provides a way of querying tags. Tags are keywords associated with a specific hostname or group. These are useful for grouping together hosts and defining common behavior for them. The tags are typically stored in a Project’s config/tags.yml
file.
For example, consider a tags.yml
file that contains YAML like:
desktops:
- satori
- sunyata
- michiru
notebooks:
- rheya
- avijja
With the above file, if we’re on the host called “satori”, we can query the fields like this:
# => ["satori", "desktops", "localhost", ...]
tagged?("desktops") # => true
tagged?("notebooks") # => false
tagged?(:satori) # => true
tagged?("satori") # => true
tagged?("satori || desktops") # => true
tagged?("(satori || desktops) && !notebooks") # => true
Defined Under Namespace
Classes: BaseDriver, Struct, TagParser, YAML
Constant Summary
Constants included from Constants
Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::VERSION, Constants::WARNING_BOILERPLATE
Instance Attribute Summary
Attributes inherited from Plugin::Manager
Attributes inherited from Common
Instance Method Summary collapse
-
#hosts_tagged_with(query) ⇒ Object
Return a list of hosts that match the query.
-
#tagged?(query, hostname = nil) ⇒ Boolean
Is this host tagged with the
query
?. -
#tags ⇒ Object
Return a list of tags for this host.
-
#tags_for(hostname) ⇒ Object
Return a list of tags for the host.
Methods inherited from Plugin::Manager
#[], abstract_manager, alias_methods, #available?, #default, #default=, #dispatch, #dispatch_safely, #dispatch_safely_to, #dispatch_to, driver_classes, #driver_for, #driver_suitability_levels_for, inherited, #instantiate_drivers, #setup
Methods inherited from Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Method Details
#hosts_tagged_with(query) ⇒ Object
Return a list of hosts that match the query. See #tagged? for information on query syntax.
32 |
# File 'lib/automateit/tag_manager.rb', line 32 def hosts_tagged_with(query) dispatch(query) end |
#tagged?(query, hostname = nil) ⇒ Boolean
Is this host tagged with the query
?
Examples:
# => ["localhost", "foo", "bar", ...]
tagged?(:localhost) # => true
tagged?("localhost") # => true
tagged?("localhost && foo") # => true
tagged?("localhost || foo") # => true
tagged?("!foo") # => false
tagged?("(localhost || foo) && bar") # => true
48 |
# File 'lib/automateit/tag_manager.rb', line 48 def tagged?(query, hostname=nil) dispatch(query, hostname) end |
#tags ⇒ Object
Return a list of tags for this host.
35 |
# File 'lib/automateit/tag_manager.rb', line 35 def () dispatch() end |
#tags_for(hostname) ⇒ Object
Return a list of tags for the host.
51 |
# File 'lib/automateit/tag_manager.rb', line 51 def (hostname) dispatch(hostname) end |