Module: QB

Includes:
SemanticLogger::Loggable
Defined in:
lib/qb.rb,
lib/qb/cli.rb,
lib/qb/data.rb,
lib/qb/util.rb,
lib/qb/errors.rb,
lib/qb/ansible.rb,
lib/qb/cli/run.rb,
lib/qb/version.rb,
lib/qb/cli/help.rb,
lib/qb/cli/play.rb,
lib/qb/repo/git.rb,
lib/qb/cli/setup.rb,
lib/qb/docker/cli.rb,
lib/qb/ansible/env.rb,
lib/qb/role/errors.rb,
lib/qb/docker/image.rb,
lib/qb/github/types.rb,
lib/qb/util/bundler.rb,
lib/qb/util/interop.rb,
lib/qb/options/types.rb,
lib/qb/util/resource.rb,
lib/qb/ansible/module.rb,
lib/qb/ansible/module.rb,
lib/qb/data/immutable.rb,
lib/qb/options/option.rb,
lib/qb/ansible/modules.rb,
lib/qb/package/version.rb,
lib/qb/util/decorators.rb,
lib/qb/docker/image/tag.rb,
lib/qb/role/default_dir.rb,
lib/qb/ansible/env/devel.rb,
lib/qb/docker/image/name.rb,
lib/qb/util/docker_mixin.rb,
lib/qb/ansible/config_file.rb,
lib/qb/ansible/cmds/playbook.rb,
lib/qb/ansible/modules/docker/image.rb,
lib/qb/options/option/option_parser_concern.rb

Overview

Definitions

Defined Under Namespace

Modules: Ansible, CLI, Data, Docker, GitHub, IPC, Labs, Python, Util Classes: AnsibleVersionError, Error, Execution, FSStateError, Options, Package, Path, QBVersionError, Repo, Role, StateError, UserInputError, VersionError

Constant Summary collapse

GEM_ROLES_DIR =

Absolute path to //roles.

Returns:

  • (Pathname)
ROOT / 'roles'
USER_ROLES_DIR =

Absolute path to the user's roles dir, which is ~/.ansible/roles.

Returns:

  • (Pathname)
ENV['HOME'].to_pn / '.ansible' / 'roles'
ROOT =

Absolute path to the gem's root directory.

Returns:

  • (Pathname)
( Pathname.new( __FILE__ ).dirname / '..' / '..' ).expand_path
GEM_NAME =

The gem's name.

Returns:

  • (String)
'qb'
VERSION =

String version read from //VERSION

Returns:

  • (String)
( ROOT / 'VERSION' ).read.chomp
MIN_ANSIBLE_VERSION =

Minimum version of Ansible required. Encoded as a Gem::Version so we can compare it.

Returns:

  • (Gem::Version)
Gem::Version.new '2.1.2'

Class Method Summary collapse

Class Method Details

.ansible_versionGem::Version

Returns the Ansible executable version parsed into a Gem version so we can compare it.

Returns:

  • (Gem::Version)

    the Ansible executable version parsed into a Gem version so we can compare it.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/qb/version.rb', line 65

def self.ansible_version
  out = Cmds.out! 'ansible --version'
  version_str = out[/ansible\ ([\d\.]+)/, 1]
  
  if version_str.nil?
    raise NRSER.dedent "      could not parse ansible version from `ansible --version` output:\n      \n      \#{ out }\n    END\n  end\n  \n  Gem::Version.new version_str\nend\n"

.check_ansible_versionObject

Check that the Ansible version is not less than MIN_ANSIBLE_VERSION.

Raises:



86
87
88
89
90
91
92
93
94
95
# File 'lib/qb/version.rb', line 86

def self.check_ansible_version
  if ansible_version < QB::MIN_ANSIBLE_VERSION
    raise QB::AnsibleVersionError, NRSER.squish(
      "        QB \#{ QB::VERSION } requires Ansible \#{ QB::MIN_ANSIBLE_VERSION },\n        found version \#{ version_str } at \#{ `which ansible` }\n      END\n    )\n  end\nend\n"

.debug(*args) ⇒ Object

Support for the old custom debug logging, now sent to SemanticLogger.



59
60
61
62
63
64
65
66
67
68
# File 'lib/qb.rb', line 59

def self.debug *args
  if args[0].is_a? String
    logger.debug *args
  else
    # De-array if there's only one arg
    args = args[0] if args.length == 1
    # And send the args to SM as the payload
    logger.debug payload: args
  end
end

.gem_versionGem::Version

Get the Gem::Version parse of VERSION.

Returns:

  • (Gem::Version)


56
57
58
# File 'lib/qb/version.rb', line 56

def self.gem_version
  Gem::Version.new VERSION
end

.gemspecObject



47
48
49
# File 'lib/qb/version.rb', line 47

def self.gemspec
  Gem.loaded_specs[GEM_NAME]
end

.local_dev?Boolean

Are we running in local development? Looks for the //dev directory's presence.

Returns:

  • (Boolean)


42
43
44
# File 'lib/qb/version.rb', line 42

def self.local_dev?
  (QB::ROOT / 'dev').directory?
end