qb 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +3 -1
- data/README.md +42 -26
- data/ansible.cfg +7 -0
- data/doc/common_issues/qb_run/slow_gather_facts.md +51 -0
- data/doc/getting_started.md +84 -0
- data/doc/intro.md +67 -0
- data/doc/notes/2018.01.06.ansible_devel_submodule.md +29 -0
- data/doc/qb_roles.md +155 -0
- data/doc/qb_roles/metadata/default_dir.md +116 -0
- data/exe/qb +16 -14
- data/lib/qb.rb +5 -20
- data/lib/qb/ansible/cmds/playbook.rb +3 -4
- data/lib/qb/ansible/env.rb +22 -2
- data/lib/qb/ansible/env/devel.rb +49 -0
- data/lib/qb/cli.rb +3 -1
- data/lib/qb/cli/help.rb +1 -1
- data/lib/qb/cli/list.rb +47 -0
- data/lib/qb/cli/run.rb +41 -15
- data/lib/qb/cli/setup.rb +35 -2
- data/lib/qb/options.rb +57 -30
- data/lib/qb/role.rb +32 -170
- data/lib/qb/role/default_dir.rb +231 -0
- data/lib/qb/role/errors.rb +18 -10
- data/lib/qb/role/name.rb +139 -0
- data/lib/qb/util/logging.rb +0 -7
- data/lib/qb/version.rb +1 -1
- data/library/stream +5 -0
- data/plugins/filter_plugins/string_plugins.py +2 -3
- data/plugins/filter_plugins/version_plugins.py +11 -0
- data/qb.gemspec +158 -62
- data/roles/nrser.blockinfile/library/blockinfile.py +14 -0
- data/roles/qb.git_repo/tasks/main.yml +3 -3
- data/roles/qb.npm_package/meta/main.yml +2 -2
- data/roles/qb.npm_package/meta/qb.yml +3 -3
- data/roles/qb.vars/meta/qb.yml +8 -7
- data/roles/qb.vars/tasks/main.yml +10 -1
- data/roles/qb/call/defaults/main.yml +2 -0
- data/roles/qb/call/meta/main.yml +8 -0
- data/roles/qb/call/meta/qb.yml +68 -0
- data/roles/qb/call/tasks/main.yml +92 -0
- data/roles/qb/gem/new/meta/qb.yml +1 -1
- data/roles/qb/gem/new/tasks/main.yml +3 -3
- data/roles/qb/gem/release/tasks/main.yml +3 -5
- data/roles/{qb.gitignore → qb/git/ignore}/defaults/main.yml +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Actionscript.gitignore +2 -3
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Ada.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Agda.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Android.gitignore +3 -2
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/AppEngine.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/AppceleratorTitanium.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ArchLinuxPackages.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Autotools.gitignore +9 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/C++.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/C.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CFWheels.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CMake.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CONTRIBUTING.md +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CUDA.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CakePHP.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ChefCookbook.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Clojure.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CodeIgniter.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CommonLisp.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Composer.gitignore +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Concrete5.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Coq.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/CraftCMS.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/D.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/DM.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Dart.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Delphi.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Drupal.gitignore +3 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/EPiServer.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Eagle.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Elisp.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Elixir.gitignore +2 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Elm.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Erlang.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ExpressionEngine.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ExtJs.gitignore +2 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Fancy.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Finale.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ForceDotCom.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Fortran.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/FuelPHP.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/GWT.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Gcov.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Gem.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/GitBook.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Anjuta.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Ansible.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Archives.gitignore +2 -2
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Bazaar.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/BricxCC.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/CVS.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Calabash.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Cloud9.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/CodeKit.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/DartEditor.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Dreamweaver.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Dropbox.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Eclipse.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/EiffelStudio.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Emacs.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Ensime.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Espresso.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/FlexBuilder.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/GPG.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/JDeveloper.gitignore +0 -0
- data/roles/qb/git/ignore/files/gitignore/Global/JEnv.gitignore +5 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/JetBrains.gitignore +2 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/KDevelop4.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Kate.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Lazarus.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/LibreOffice.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Linux.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/LyX.gitignore +0 -0
- data/roles/qb/git/ignore/files/gitignore/Global/Matlab.gitignore +25 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Mercurial.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/MicrosoftOffice.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/ModelSim.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Momentics.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/MonoDevelop.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/NetBeans.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Ninja.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/NotepadPP.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Otto.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/README.md +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Redcar.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Redis.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SBT.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SVN.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SlickEdit.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Stata.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SublimeText.gitignore +5 -5
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/SynopsysVCS.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Tags.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/TextMate.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/TortoiseGit.gitignore +0 -0
- data/roles/qb/git/ignore/files/gitignore/Global/Vagrant.gitignore +5 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Vim.gitignore +6 -4
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/VirtualEnv.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/VisualStudioCode.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/WebMethods.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Windows.gitignore +4 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/Xcode.gitignore +9 -9
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/XilinxISE.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Global/macOS.gitignore +2 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Go.gitignore +0 -3
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Gradle.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Grails.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Haskell.gitignore +2 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/IGORPro.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Idris.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Java.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Jboss.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Jekyll.gitignore +1 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Joomla.gitignore +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Julia.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/KiCad.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Kohana.gitignore +0 -0
- data/roles/qb/git/ignore/files/gitignore/Kotlin.gitignore +1 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/LICENSE +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/LabVIEW.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Laravel.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Leiningen.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/LemonStand.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Lilypond.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Lithium.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Lua.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Magento.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Maven.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Mercury.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/MetaProgrammingSystem.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Nanoc.gitignore +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Nim.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Node.gitignore +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/OCaml.gitignore +3 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Objective-C.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Opa.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/OpenCart.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/OracleForms.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Packer.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Perl.gitignore +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Phalcon.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/PlayFramework.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Plone.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Prestashop.gitignore +3 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Processing.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/PureScript.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Python.gitignore +11 -5
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/QB.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Qooxdoo.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Qt.gitignore +8 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/R.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/README.md +2 -2
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ROS.gitignore +2 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Rails.gitignore +4 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/RhodesRhomobile.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Ruby.gitignore +0 -16
- data/roles/qb/git/ignore/files/gitignore/RubyMotion.gitignore +30 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Rust.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SCons.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Sass.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Scala.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Scheme.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Scrivener.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Sdcc.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SeamGen.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SketchUp.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Smalltalk.gitignore +4 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Stella.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SugarCRM.gitignore +2 -2
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Swift.gitignore +1 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Symfony.gitignore +7 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/SymphonyCMS.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/TeX.gitignore +6 -1
- data/roles/qb/git/ignore/files/gitignore/Terraform.gitignore +9 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Textpattern.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/TurboGears2.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Typo3.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Umbraco.gitignore +7 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Unity.gitignore +7 -6
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/UnrealEngine.gitignore +2 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/VVVV.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/VisualStudio.gitignore +37 -6
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Waf.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/WordPress.gitignore +1 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Xojo.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Yeoman.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Yii.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/ZendFramework.gitignore +0 -1
- data/roles/{qb.gitignore → qb/git/ignore}/files/gitignore/Zephir.gitignore +0 -0
- data/roles/{qb.gitignore → qb/git/ignore}/meta/main.yml +1 -1
- data/roles/{qb.gitignore → qb/git/ignore}/meta/qb +5 -0
- data/roles/{qb.gitignore → qb/git/ignore}/tasks/main.yml +9 -1
- data/roles/qb/github/pages/setup/defaults/main.yml +2 -0
- data/roles/qb/github/pages/setup/meta/main.yml +8 -0
- data/roles/qb/github/pages/setup/meta/qb.yml +68 -0
- data/roles/qb/github/pages/setup/tasks/main.yml +10 -0
- data/roles/{qb.project → qb/project}/.qb-options.yml +1 -1
- data/roles/{qb.project → qb/project}/defaults/main.yml +1 -1
- data/roles/{qb.project → qb/project}/files/ansible.cfg +0 -0
- data/roles/{qb.project → qb/project}/files/hosts +0 -0
- data/roles/qb/project/meta/main.yml +6 -0
- data/roles/{qb.project → qb/project}/meta/qb.yml +4 -2
- data/roles/{qb.project → qb/project}/qb/get_dir +0 -0
- data/roles/qb/project/tasks/dev.yml +53 -0
- data/roles/{qb.project → qb/project}/tasks/main.yml +3 -2
- data/roles/{qb.project → qb/project}/templates/.gitkeep +0 -0
- data/roles/qb/project/templates/README.md.j2 +4 -0
- data/roles/qb/project/templates/setup.qb.yml.j2 +52 -0
- data/roles/{qb.project → qb/project}/templates/setup.yml.j2 +0 -0
- data/roles/{qb.role → qb/role}/.qb-options.yml +0 -0
- data/roles/{qb.role → qb/role}/defaults/main.yml +4 -1
- data/roles/{qb.role → qb/role}/meta/main.yml +1 -1
- data/roles/{qb.role → qb/role}/meta/qb.yml +2 -2
- data/roles/qb/role/qb/meta/main.yml +1 -1
- data/roles/qb/role/qb/meta/qb.yml +1 -1
- data/roles/qb/role/qb/tasks/main.yml +4 -2
- data/roles/qb/role/qb/templates/qb.yml.j2 +1 -1
- data/roles/{qb.role → qb/role}/tasks/main.yml +3 -2
- data/roles/{qb.role → qb/role}/tasks/module.yml +0 -0
- data/roles/{qb.role → qb/role}/tasks/plugins/_filter_plugin.yml +0 -0
- data/roles/{qb.role → qb/role}/tasks/plugins/filter_plugins.yml +5 -5
- data/roles/{qb.role → qb/role}/templates/.gitkeep +0 -0
- data/roles/{qb.role → qb/role}/templates/README.md.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/defaults/main.yml.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/filter_plugins/filters.py.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/handlers/main.yml.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/library/module.rb.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/meta/main.yml.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/tasks/main.yml.j2 +0 -0
- data/roles/{qb.role → qb/role}/templates/vars/main.yml.j2 +0 -0
- data/roles/{qb.role → qb/role}/vars/main.yml +1 -1
- data/roles/qb/ruby/bundler/.qb-options.yml +4 -0
- data/roles/qb/ruby/bundler/defaults/main.yml +7 -0
- data/roles/qb/ruby/bundler/filter_plugins/bundler_filters.py +157 -0
- data/roles/qb/ruby/bundler/meta/main.yml +8 -0
- data/roles/qb/ruby/bundler/meta/qb.yml +69 -0
- data/roles/qb/ruby/bundler/tasks/gems.yml +12 -0
- data/roles/qb/ruby/bundler/tasks/main.yml +12 -0
- data/roles/qb/ruby/bundler/tasks/setup.yml +13 -0
- data/roles/qb/ruby/yard/defaults/args.yml +2 -0
- data/roles/qb/ruby/yard/defaults/main.yml +9 -0
- data/roles/qb/ruby/yard/meta/main.yml +8 -0
- data/roles/qb/ruby/yard/meta/qb.yml +71 -0
- data/roles/qb/ruby/yard/tasks/main.yml +28 -0
- metadata +290 -297
- data/roles/nrser.blockinfile/tests/.gitignore +0 -1
- data/roles/nrser.blockinfile/tests/expected/test-basic/create.txt +0 -5
- data/roles/nrser.blockinfile/tests/expected/test-basic/insert.txt +0 -6
- data/roles/nrser.blockinfile/tests/expected/test-basic/marker.txt +0 -5
- data/roles/nrser.blockinfile/tests/expected/test-basic/remove.txt +0 -2
- data/roles/nrser.blockinfile/tests/expected/test-basic/update.txt +0 -6
- data/roles/nrser.blockinfile/tests/expected/test-block/block.txt +0 -4
- data/roles/nrser.blockinfile/tests/expected/test-block/content.txt +0 -4
- data/roles/nrser.blockinfile/tests/expected/test-follow/link0.txt +0 -6
- data/roles/nrser.blockinfile/tests/expected/test-follow/link1.txt +0 -6
- data/roles/nrser.blockinfile/tests/expected/test-follow/link2.txt +0 -1
- data/roles/nrser.blockinfile/tests/expected/test-follow/real0.txt +0 -2
- data/roles/nrser.blockinfile/tests/expected/test-follow/real1.txt +0 -2
- data/roles/nrser.blockinfile/tests/expected/test-follow/real2.txt +0 -6
- data/roles/nrser.blockinfile/tests/expected/test-insertab/insertafter.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-insertab/insertbefore.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-insertab/insertbof.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-insertab/inserteof.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-insertab/insertunmatched.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-insertab/updateafter.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-insertab/updatebefore.txt +0 -8
- data/roles/nrser.blockinfile/tests/expected/test-multiline/insert.txt +0 -11
- data/roles/nrser.blockinfile/tests/expected/test-multiline/remove.txt +0 -2
- data/roles/nrser.blockinfile/tests/expected/test-multiline/update.txt +0 -12
- data/roles/nrser.blockinfile/tests/expected/test-replace/index.html +0 -6
- data/roles/nrser.blockinfile/tests/expected/test-state/insert-present.txt +0 -5
- data/roles/nrser.blockinfile/tests/expected/test-state/insert.txt +0 -5
- data/roles/nrser.blockinfile/tests/expected/test-state/remove-absent.txt +0 -2
- data/roles/nrser.blockinfile/tests/expected/test-state/remove-present.txt +0 -2
- data/roles/nrser.blockinfile/tests/expected/test-state/remove.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-basic/insert.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-basic/marker.txt +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-basic/remove.txt +0 -6
- data/roles/nrser.blockinfile/tests/fixtures/test-basic/update.txt +0 -6
- data/roles/nrser.blockinfile/tests/fixtures/test-block/block.txt +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-block/content.txt +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/link0.txt +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/link1.txt +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/link2.txt +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/real0.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/real1.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/real2.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertafter.txt +0 -4
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertbefore.txt +0 -4
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertbof.txt +0 -4
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/inserteof.txt +0 -4
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/insertunmatched.txt +0 -4
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/updateafter.txt +0 -8
- data/roles/nrser.blockinfile/tests/fixtures/test-insertab/updatebefore.txt +0 -8
- data/roles/nrser.blockinfile/tests/fixtures/test-multiline/insert.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-multiline/remove.txt +0 -11
- data/roles/nrser.blockinfile/tests/fixtures/test-multiline/update.txt +0 -12
- data/roles/nrser.blockinfile/tests/fixtures/test-replace/index.html +0 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-state/insert-present.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-state/insert.txt +0 -2
- data/roles/nrser.blockinfile/tests/fixtures/test-state/remove-absent.txt +0 -6
- data/roles/nrser.blockinfile/tests/fixtures/test-state/remove-present.txt +0 -6
- data/roles/nrser.blockinfile/tests/fixtures/test-state/remove.txt +0 -6
- data/roles/nrser.blockinfile/tests/hosts +0 -1
- data/roles/nrser.blockinfile/tests/roles/yaegashi.blockinfile +0 -1
- data/roles/nrser.blockinfile/tests/run.sh +0 -64
- data/roles/nrser.blockinfile/tests/test-basic.yml +0 -31
- data/roles/nrser.blockinfile/tests/test-block.yml +0 -16
- data/roles/nrser.blockinfile/tests/test-follow.yml +0 -21
- data/roles/nrser.blockinfile/tests/test-insertab.yml +0 -34
- data/roles/nrser.blockinfile/tests/test-multiline.yml +0 -51
- data/roles/nrser.blockinfile/tests/test-replace.yml +0 -21
- data/roles/nrser.blockinfile/tests/test-state.yml +0 -32
- data/roles/qb.gitignore/files/gitignore/Global/Matlab.gitignore +0 -22
- data/roles/qb.gitignore/files/gitignore/Global/Vagrant.gitignore +0 -1
- data/roles/qb.gitignore/files/gitignore/Terraform.gitignore +0 -6
- data/roles/qb.project/meta/main.yml +0 -6
- data/roles/qb.project/tasks/dev.yml +0 -36
- data/roles/qb.project/tasks/setup.yml +0 -42
- data/roles/qb.project/templates/README.md.j2 +0 -2
- data/roles/qb.project/templates/bootstrap.yml.j2 +0 -20
data/lib/qb/cli/setup.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
# Requirements
|
2
2
|
# =====================================================================
|
3
3
|
|
4
|
+
# StdLib
|
5
|
+
require 'pathname'
|
6
|
+
|
4
7
|
# package
|
5
8
|
require 'qb/ansible/cmds/playbook'
|
6
9
|
|
7
10
|
|
11
|
+
# Refinements
|
12
|
+
# =======================================================================
|
13
|
+
|
14
|
+
require 'nrser/refinements'
|
15
|
+
using NRSER
|
16
|
+
|
17
|
+
|
8
18
|
# Declarations
|
9
19
|
# =======================================================================
|
10
20
|
|
@@ -25,8 +35,31 @@ module QB::CLI
|
|
25
35
|
# The `ansible-playbook` command exit code.
|
26
36
|
#
|
27
37
|
def self.setup args = []
|
28
|
-
|
29
|
-
|
38
|
+
# Figure out project root and setup playbook path
|
39
|
+
case args[0]
|
40
|
+
when String, Pathname
|
41
|
+
# The playbook path has been provided, use that to find the project root
|
42
|
+
playbook_path = QB::Util.resolve args[0]
|
43
|
+
project_root = NRSER.git_root playbook_path
|
44
|
+
|
45
|
+
when nil
|
46
|
+
# Figure the project root out from the current directory, then
|
47
|
+
# form the playbook path from that
|
48
|
+
project_root = NRSER.git_root '.'
|
49
|
+
playbook_path = project_root / 'dev' / 'setup.qb.yml'
|
50
|
+
|
51
|
+
else
|
52
|
+
raise TypeError.new binding.erb <<-END
|
53
|
+
First entry of `args` must be nil, String or Pathname, found:
|
54
|
+
|
55
|
+
<%= args[0].pretty_inspect %>
|
56
|
+
|
57
|
+
args:
|
58
|
+
|
59
|
+
<%= args.pretty_inspect %>
|
60
|
+
|
61
|
+
END
|
62
|
+
end
|
30
63
|
|
31
64
|
unless playbook_path.file?
|
32
65
|
raise "Can't find QB setup playbook at `#{ playbook_path.to_s }`"
|
data/lib/qb/options.rb
CHANGED
@@ -10,7 +10,13 @@ using NRSER
|
|
10
10
|
|
11
11
|
module QB
|
12
12
|
class Options
|
13
|
-
#
|
13
|
+
# Mixins
|
14
|
+
# ========================================================================
|
15
|
+
|
16
|
+
include SemanticLogger::Loggable
|
17
|
+
|
18
|
+
|
19
|
+
# Constants
|
14
20
|
# =======================================================================
|
15
21
|
|
16
22
|
QB_DEFAULTS = {
|
@@ -103,6 +109,8 @@ module QB
|
|
103
109
|
|
104
110
|
QB.debug "including #{ role.name } as #{ new_include_path.join('-') }"
|
105
111
|
|
112
|
+
opts.separator "Options for included #{ role.name } role:"
|
113
|
+
|
106
114
|
add opts, options, role, new_include_path
|
107
115
|
end
|
108
116
|
|
@@ -353,6 +361,8 @@ module QB
|
|
353
361
|
|
354
362
|
opts.banner = @role.banner
|
355
363
|
|
364
|
+
opts.separator "Common options:"
|
365
|
+
|
356
366
|
opts.on(
|
357
367
|
'-H',
|
358
368
|
'--HOSTS=HOSTS',
|
@@ -457,6 +467,8 @@ module QB
|
|
457
467
|
@qb['ask'] = value
|
458
468
|
end
|
459
469
|
|
470
|
+
opts.separator "Role options:"
|
471
|
+
|
460
472
|
self.class.add opts, @role_options, @role
|
461
473
|
|
462
474
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -471,37 +483,52 @@ module QB
|
|
471
483
|
opt_parser.parse! @argv
|
472
484
|
end # parse!
|
473
485
|
|
474
|
-
|
475
|
-
|
476
|
-
#
|
477
|
-
# 1. `--ANSIBLE-`
|
478
|
-
# 2. `---`
|
479
|
-
#
|
480
|
-
# out of `@argv` and stick them in `@ansible`.
|
481
|
-
def parse_ansible!
|
482
|
-
@ansible = @role.default_ansible_options.clone
|
483
|
-
|
484
|
-
reg_exs = [
|
485
|
-
/\A\-\-ANSIBLE[\-\_]/,
|
486
|
-
/\A\-\-\-/,
|
487
|
-
]
|
486
|
+
|
487
|
+
protected
|
488
|
+
# ========================================================================
|
488
489
|
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
490
|
+
# Pull options that start with
|
491
|
+
#
|
492
|
+
# 1. `--ANSIBLE_`
|
493
|
+
# 1. `--ANSIBLE-`
|
494
|
+
# 2. `---`
|
495
|
+
#
|
496
|
+
# out of `@argv` and stick them in `@ansible`.
|
497
|
+
#
|
498
|
+
# @return [nil]
|
499
|
+
# **Mutates** `@argv`.
|
500
|
+
#
|
501
|
+
def parse_ansible!
|
502
|
+
logger.debug "Parsing Ansible options...",
|
503
|
+
argv: @argv.dup
|
504
|
+
|
505
|
+
@ansible = @role.default_ansible_options.clone
|
506
|
+
|
507
|
+
reg_exs = [
|
508
|
+
/\A\-\-ANSIBLE[\-\_]/,
|
509
|
+
/\A\-\-\-/,
|
510
|
+
]
|
511
|
+
|
512
|
+
@argv.reject! {|shellword|
|
513
|
+
if re = reg_exs.find {|re| re =~ shellword}
|
514
|
+
name = shellword.sub re, ''
|
515
|
+
|
516
|
+
value = true
|
517
|
+
|
518
|
+
if name.include? '='
|
519
|
+
name, value = name.split('=', 2)
|
520
|
+
end
|
521
|
+
|
522
|
+
@ansible[name] = value
|
523
|
+
|
524
|
+
true
|
497
525
|
end
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
end # #parse_ansible!
|
526
|
+
}
|
527
|
+
|
528
|
+
nil
|
529
|
+
end # #parse_ansible!
|
530
|
+
|
531
|
+
# end protected
|
505
532
|
|
506
533
|
end # Options
|
507
534
|
end # QB
|
data/lib/qb/role.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
|
-
|
2
1
|
# Requirements
|
3
2
|
# =======================================================================
|
4
3
|
|
5
4
|
# stdlib
|
5
|
+
# ----------------------------------------------------------------------------
|
6
|
+
|
6
7
|
require 'yaml'
|
7
8
|
require 'cmds'
|
8
9
|
|
10
|
+
|
9
11
|
# deps
|
12
|
+
# ----------------------------------------------------------------------------
|
13
|
+
|
10
14
|
|
11
15
|
# package
|
12
|
-
|
16
|
+
# ----------------------------------------------------------------------------
|
17
|
+
|
18
|
+
# Breakouts
|
19
|
+
require 'qb/role/errors'
|
20
|
+
require 'qb/role/name'
|
21
|
+
require 'qb/role/default_dir'
|
13
22
|
|
14
23
|
|
15
24
|
# Refinements
|
@@ -29,6 +38,12 @@ module QB; end
|
|
29
38
|
#
|
30
39
|
class QB::Role
|
31
40
|
|
41
|
+
# Mixins
|
42
|
+
# ============================================================================
|
43
|
+
|
44
|
+
include SemanticLogger::Loggable
|
45
|
+
|
46
|
+
|
32
47
|
# Constants
|
33
48
|
# =====================================================================
|
34
49
|
|
@@ -219,10 +234,12 @@ class QB::Role
|
|
219
234
|
search_dir.directory?
|
220
235
|
}.
|
221
236
|
map {|search_dir|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
237
|
+
['', '.yml', '.yaml'].flat_map { |ext|
|
238
|
+
Pathname.glob(search_dir.join '**', 'meta', "qb#{ ext }").
|
239
|
+
map {|meta_path|
|
240
|
+
[meta_path.dirname.dirname, search_dir: search_dir]
|
241
|
+
}
|
242
|
+
}
|
226
243
|
}.
|
227
244
|
flatten(1).
|
228
245
|
map {|args|
|
@@ -403,58 +420,6 @@ class QB::Role
|
|
403
420
|
end
|
404
421
|
|
405
422
|
|
406
|
-
# Do our best to figure out a role name from a path (that might not exist).
|
407
|
-
#
|
408
|
-
# We needs this for when we're creating a role.
|
409
|
-
#
|
410
|
-
# @param [String | Pathname] path
|
411
|
-
#
|
412
|
-
#
|
413
|
-
# @return [String]
|
414
|
-
#
|
415
|
-
def self.default_role_name path
|
416
|
-
resolved_path = QB::Util.resolve path
|
417
|
-
|
418
|
-
# Find the first directory in the search path that contains the path,
|
419
|
-
# if any do.
|
420
|
-
#
|
421
|
-
# It *could* be in more than one in funky situations like overlapping
|
422
|
-
# search paths or link silliness, but that doesn't matter - we consider
|
423
|
-
# the first place we find it to be the relevant once, since the search
|
424
|
-
# path is most-important-first.
|
425
|
-
#
|
426
|
-
search_dir = search_path.find { |pathname|
|
427
|
-
resolved_path.fnmatch? ( pathname / '**' ).to_s
|
428
|
-
}
|
429
|
-
|
430
|
-
if search_dir.nil?
|
431
|
-
# It's not in any of the search directories
|
432
|
-
#
|
433
|
-
# If it has 'roles' as a segment than use what's after the last occurrence
|
434
|
-
# of that (unless there isn't anything).
|
435
|
-
#
|
436
|
-
segments = resolved_path.to_s.split File::SEPARATOR
|
437
|
-
|
438
|
-
if index = segments.rindex( 'roles' )
|
439
|
-
name_segs = segments[( index + 1 )..( -1 )]
|
440
|
-
|
441
|
-
unless name_segs.empty?
|
442
|
-
return File.join name_segs
|
443
|
-
end
|
444
|
-
end
|
445
|
-
|
446
|
-
# Ok, that didn't work... just return the basename I guess...
|
447
|
-
return File.basename resolved_path
|
448
|
-
|
449
|
-
end
|
450
|
-
|
451
|
-
# it's in the search path, return the relative path from the containing
|
452
|
-
# search dir to the resolved path (string version of it).
|
453
|
-
resolved_path.relative_path_from( search_dir ).to_s
|
454
|
-
|
455
|
-
end # #default_role_name
|
456
|
-
|
457
|
-
|
458
423
|
# Instance Attributes
|
459
424
|
# =======================================================================
|
460
425
|
|
@@ -534,22 +499,6 @@ class QB::Role
|
|
534
499
|
# Instance Methods
|
535
500
|
# =====================================================================
|
536
501
|
|
537
|
-
def namespace
|
538
|
-
*namespace_segments, last = @name.split File::Separator
|
539
|
-
|
540
|
-
namespace_segments << last.split('.').first if last.include?('.')
|
541
|
-
|
542
|
-
if namespace_segments.empty?
|
543
|
-
nil
|
544
|
-
else
|
545
|
-
File.join *namespace_segments
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
|
-
def namespaceless
|
550
|
-
File.basename(@name).split('.', 2).last
|
551
|
-
end
|
552
|
-
|
553
502
|
def options_key
|
554
503
|
@display_path.to_s
|
555
504
|
end
|
@@ -695,7 +644,7 @@ class QB::Role
|
|
695
644
|
parts << '[OPTIONS]'
|
696
645
|
end
|
697
646
|
|
698
|
-
if
|
647
|
+
if has_dir_arg?
|
699
648
|
parts << 'DIRECTORY'
|
700
649
|
end
|
701
650
|
|
@@ -715,10 +664,11 @@ class QB::Role
|
|
715
664
|
lines << meta['description']
|
716
665
|
lines << ''
|
717
666
|
end
|
718
|
-
lines << '
|
667
|
+
lines << 'Usage:'
|
668
|
+
lines << ''
|
719
669
|
lines << " #{ usage }"
|
720
670
|
lines << ''
|
721
|
-
lines << '
|
671
|
+
lines << ''
|
722
672
|
|
723
673
|
lines.join("\n")
|
724
674
|
end
|
@@ -776,102 +726,14 @@ class QB::Role
|
|
776
726
|
end
|
777
727
|
|
778
728
|
|
729
|
+
# Test if the {QB::Role} uses a directory argument (that gets assigned to
|
730
|
+
# the `qb_dir` variable in Ansible).
|
731
|
+
#
|
779
732
|
# @return [Boolean]
|
780
|
-
# @todo Document return value.
|
781
733
|
#
|
782
|
-
def
|
734
|
+
def has_dir_arg?
|
783
735
|
meta['default_dir'] != false
|
784
|
-
end # #
|
785
|
-
|
786
|
-
|
787
|
-
# gets the default `qb_dir` value, raising an error if the role doesn't
|
788
|
-
# define how to get one or there is a problem getting it.
|
789
|
-
#
|
790
|
-
#
|
791
|
-
def default_dir cwd, options
|
792
|
-
QB.debug "get_default_dir",
|
793
|
-
role: self,
|
794
|
-
meta: self.meta,
|
795
|
-
cwd: cwd,
|
796
|
-
options: options
|
797
|
-
|
798
|
-
key = 'default_dir'
|
799
|
-
value = self.meta[key]
|
800
|
-
case value
|
801
|
-
when nil
|
802
|
-
# there is no get_dir info in meta/qb.yml, can't get the dir
|
803
|
-
raise QB::UserInputError.dedented <<-END
|
804
|
-
unable to infer default directory: no '#{ key }' key in 'meta/qb.yml'
|
805
|
-
for role #{ self }
|
806
|
-
END
|
807
|
-
|
808
|
-
when false
|
809
|
-
# this method should not get called when the value is false (an entire
|
810
|
-
# section is skipped in exe/qb when `default_dir = false`)
|
811
|
-
raise QB::StateError.squished <<-END
|
812
|
-
role does not use default directory (meta/qb.yml:default_dir = false)
|
813
|
-
END
|
814
|
-
|
815
|
-
when 'git_root'
|
816
|
-
QB.debug "returning the git root relative to cwd"
|
817
|
-
NRSER.git_root cwd
|
818
|
-
|
819
|
-
when 'cwd'
|
820
|
-
QB.debug "returning current working directory"
|
821
|
-
cwd
|
822
|
-
|
823
|
-
when Hash
|
824
|
-
QB.debug "qb meta option is a Hash"
|
825
|
-
|
826
|
-
unless value.length == 1
|
827
|
-
raise "#{ meta_path.to_s }:default_dir invalid: #{ value.inspect }"
|
828
|
-
end
|
829
|
-
|
830
|
-
hash_key, hash_value = value.first
|
831
|
-
|
832
|
-
case hash_key
|
833
|
-
when 'exe'
|
834
|
-
exe_path = hash_value
|
835
|
-
|
836
|
-
# supply the options to the exe so it can make work off those values
|
837
|
-
# if it wants.
|
838
|
-
exe_input_data = Hash[
|
839
|
-
options.map {|option|
|
840
|
-
[option.cli_option_name, option.value]
|
841
|
-
}
|
842
|
-
]
|
843
|
-
|
844
|
-
unless exe_path.start_with?('~') || exe_path.start_with?('/')
|
845
|
-
exe_path = File.join(self.path, exe_path)
|
846
|
-
debug 'exe path is relative, basing off role dir', exe_path: exe_path
|
847
|
-
end
|
848
|
-
|
849
|
-
debug "found 'exe' key, calling", exe_path: exe_path,
|
850
|
-
exe_input_data: exe_input_data
|
851
|
-
|
852
|
-
Cmds.chomp! exe_path do
|
853
|
-
JSON.dump exe_input_data
|
854
|
-
end
|
855
|
-
|
856
|
-
when 'find_up'
|
857
|
-
filename = hash_value
|
858
|
-
|
859
|
-
unless filename.is_a? String
|
860
|
-
raise "find_up filename must be string, found #{ filename.inspect }"
|
861
|
-
end
|
862
|
-
|
863
|
-
QB.debug "found 'find_up', looking for file named #{ filename }"
|
864
|
-
|
865
|
-
QB::Util.find_up filename
|
866
|
-
|
867
|
-
else
|
868
|
-
raise QB::Role::MetadataError.squised <<-END
|
869
|
-
bad key: #{ hash_key } in #{ self.meta_path.to_s }:default_dir
|
870
|
-
END
|
871
|
-
|
872
|
-
end
|
873
|
-
end
|
874
|
-
end # default_dir
|
736
|
+
end # #has_dir_arg?
|
875
737
|
|
876
738
|
|
877
739
|
# @return [Hash<String, *>]
|
@@ -0,0 +1,231 @@
|
|
1
|
+
##
|
2
|
+
# {QB::Role} methods for finding the default directory for
|
3
|
+
# running a role when one is not provided in the CLI.
|
4
|
+
#
|
5
|
+
# Broken out from the main `//lib/qb/role.rb` file because it was starting to
|
6
|
+
# get long and unwieldy.
|
7
|
+
#
|
8
|
+
##
|
9
|
+
|
10
|
+
|
11
|
+
# Requirements
|
12
|
+
# =======================================================================
|
13
|
+
|
14
|
+
# Stdlib
|
15
|
+
# -----------------------------------------------------------------------
|
16
|
+
require 'pathname'
|
17
|
+
|
18
|
+
# Deps
|
19
|
+
# -----------------------------------------------------------------------
|
20
|
+
|
21
|
+
# Project / Package
|
22
|
+
# -----------------------------------------------------------------------
|
23
|
+
|
24
|
+
|
25
|
+
# Refinements
|
26
|
+
# =======================================================================
|
27
|
+
|
28
|
+
require 'nrser/refinements'
|
29
|
+
using NRSER
|
30
|
+
|
31
|
+
|
32
|
+
# Declarations
|
33
|
+
# =======================================================================
|
34
|
+
|
35
|
+
module QB; end
|
36
|
+
|
37
|
+
|
38
|
+
# Definitions
|
39
|
+
# =======================================================================
|
40
|
+
|
41
|
+
class QB::Role
|
42
|
+
|
43
|
+
# Instance Methods
|
44
|
+
# ======================================================================
|
45
|
+
|
46
|
+
# Gets the default `qb_dir` value, raising an error if the role doesn't
|
47
|
+
# define how to get one or there is a problem getting it.
|
48
|
+
#
|
49
|
+
# It uses a "strategy" value found at the 'default_dir' key in the role's
|
50
|
+
# QB metadata (in `<role_path>/meta/qb.yml` or returned by a
|
51
|
+
# `<role_path>/meta/qb` executable).
|
52
|
+
#
|
53
|
+
# See the {file:doc/qb_roles/metadata/default_dir.md default_dir}
|
54
|
+
# documentation for details on the accepted strategy values.
|
55
|
+
#
|
56
|
+
# @param [String | Pathname] cwd:
|
57
|
+
# The working directory the CLI command was run in.
|
58
|
+
#
|
59
|
+
# @param [Hash<String, QB::Options::Option>] options:
|
60
|
+
# The role options (from {QB::Options#role_options}).
|
61
|
+
#
|
62
|
+
# TODO rename this.
|
63
|
+
#
|
64
|
+
# @return [Pathname]
|
65
|
+
# The directory to target.
|
66
|
+
#
|
67
|
+
# @raise
|
68
|
+
# When we can't determine a directory due to role meta settings or target
|
69
|
+
# system state.
|
70
|
+
#
|
71
|
+
def default_dir cwd, options
|
72
|
+
logger.debug "CALLING default_dir",
|
73
|
+
role: self.instance_variables.map_values { |k, v|
|
74
|
+
self.instance_variable_get k
|
75
|
+
},
|
76
|
+
cwd: cwd,
|
77
|
+
options: options
|
78
|
+
|
79
|
+
default_dir_for(
|
80
|
+
value: self.meta['default_dir'],
|
81
|
+
cwd: cwd,
|
82
|
+
options: options
|
83
|
+
).to_pn
|
84
|
+
end # default_dir
|
85
|
+
|
86
|
+
|
87
|
+
protected
|
88
|
+
# ========================================================================
|
89
|
+
|
90
|
+
# Internal, possibly recursive method that actually does the work of
|
91
|
+
# figuring out the directory value.
|
92
|
+
#
|
93
|
+
# Recurs when the meta value is an array, trying each of the entries in
|
94
|
+
# sequence, returning the first to succeed, and raising if they all fail.
|
95
|
+
#
|
96
|
+
# @param [nil | false | String | Hash | Array] strategy
|
97
|
+
# Instruction for how to determine the directory value.
|
98
|
+
#
|
99
|
+
# See the {file:doc/qb_roles.md#default_dir default_dir} for a details
|
100
|
+
# on recognized values.
|
101
|
+
#
|
102
|
+
# @return [return_type]
|
103
|
+
# @todo Document return value.
|
104
|
+
#
|
105
|
+
def default_dir_for value:, cwd:, options:
|
106
|
+
case value
|
107
|
+
when nil
|
108
|
+
# there is no get_dir info in meta/qb.yml, can't get the dir
|
109
|
+
raise QB::UserInputError.new binding.erb <<-END
|
110
|
+
No default directory for role <%= self.name %>
|
111
|
+
|
112
|
+
Role <%= self.name %> does not provide a default target directory
|
113
|
+
(used to populate the `qb_dir` Ansible variable).
|
114
|
+
|
115
|
+
You must provide one via the CLI like
|
116
|
+
|
117
|
+
qb run <%= self.name %> DIRECTORY
|
118
|
+
|
119
|
+
or, if you are the developer of the <%= self.name %> role, set a
|
120
|
+
non-null value for the 'default_dir' key in
|
121
|
+
|
122
|
+
<%= self.meta_path %>
|
123
|
+
|
124
|
+
END
|
125
|
+
|
126
|
+
when false
|
127
|
+
# this method should not get called when the value is false (an entire
|
128
|
+
# section is skipped in exe/qb when `default_dir = false`)
|
129
|
+
raise QB::StateError.squished <<-END
|
130
|
+
role does not use default directory (meta/qb.yml:default_dir = false)
|
131
|
+
END
|
132
|
+
|
133
|
+
when 'git_root'
|
134
|
+
logger.debug "returning the git root relative to cwd"
|
135
|
+
NRSER.git_root cwd
|
136
|
+
|
137
|
+
when 'cwd'
|
138
|
+
logger.debug "returning current working directory"
|
139
|
+
cwd
|
140
|
+
|
141
|
+
when Hash
|
142
|
+
logger.debug "qb meta option is a Hash"
|
143
|
+
|
144
|
+
unless value.length == 1
|
145
|
+
raise "#{ meta_path.to_s }:default_dir invalid: #{ value.inspect }"
|
146
|
+
end
|
147
|
+
|
148
|
+
hash_key, hash_value = value.first
|
149
|
+
|
150
|
+
case hash_key
|
151
|
+
when 'exe'
|
152
|
+
exe_path = hash_value
|
153
|
+
|
154
|
+
# supply the options to the exe so it can make work off those values
|
155
|
+
# if it wants.
|
156
|
+
exe_input_data = Hash[
|
157
|
+
options.map {|option|
|
158
|
+
[option.cli_option_name, option.value]
|
159
|
+
}
|
160
|
+
]
|
161
|
+
|
162
|
+
unless exe_path.start_with?('~') || exe_path.start_with?('/')
|
163
|
+
exe_path = File.join(self.path, exe_path)
|
164
|
+
debug 'exe path is relative, basing off role dir', exe_path: exe_path
|
165
|
+
end
|
166
|
+
|
167
|
+
debug "found 'exe' key, calling", exe_path: exe_path,
|
168
|
+
exe_input_data: exe_input_data
|
169
|
+
|
170
|
+
Cmds.chomp! exe_path do
|
171
|
+
JSON.dump exe_input_data
|
172
|
+
end
|
173
|
+
|
174
|
+
when 'find_up'
|
175
|
+
filename = hash_value
|
176
|
+
|
177
|
+
unless filename.is_a? String
|
178
|
+
raise "find_up filename must be string, found #{ filename.inspect }"
|
179
|
+
end
|
180
|
+
|
181
|
+
QB.debug "found 'find_up', looking for file named #{ filename }"
|
182
|
+
|
183
|
+
QB::Util.find_up filename
|
184
|
+
|
185
|
+
when 'from_role'
|
186
|
+
# Get the value from another role, presumably one this role includes
|
187
|
+
|
188
|
+
default_dir_for \
|
189
|
+
value: QB::Role.require( hash_value ).meta['default_dir'],
|
190
|
+
cwd: cwd,
|
191
|
+
options: options
|
192
|
+
|
193
|
+
else
|
194
|
+
raise QB::Role::MetadataError.new binding.erb <<-END
|
195
|
+
Bad key <%= hash_key.inspect %> in 'default_dir' value
|
196
|
+
|
197
|
+
Metadata for role <%= name %> read from
|
198
|
+
|
199
|
+
<%= self.meta_path.to_s %>
|
200
|
+
|
201
|
+
contains an invalid default directory strategy
|
202
|
+
|
203
|
+
<%= value.pretty_inspect %>
|
204
|
+
|
205
|
+
The key <%= hash_key.inspect %> does not correspond to a recognized
|
206
|
+
form.
|
207
|
+
|
208
|
+
Valid forms are:
|
209
|
+
|
210
|
+
1. {exe: FILEPATH}
|
211
|
+
2. {file_up: FILEPATH}
|
212
|
+
3. {from_role: ROLE}
|
213
|
+
|
214
|
+
END
|
215
|
+
end
|
216
|
+
|
217
|
+
when Array
|
218
|
+
value.try_find do |candidate|
|
219
|
+
default_dir_for value: candidate, cwd: cwd, options: options
|
220
|
+
end
|
221
|
+
|
222
|
+
else
|
223
|
+
raise QB::Role::MetadataError.new binding.erb <<-END
|
224
|
+
bad default_dir value: <%= value %>
|
225
|
+
END
|
226
|
+
end # case value
|
227
|
+
end # .default_dir_for
|
228
|
+
|
229
|
+
# end protected
|
230
|
+
|
231
|
+
end # class QB::Role
|