项目作者: saab-simc-admin

项目描述 :
Lightweight Inventory/Asset/Configuration Management Database
高级语言: Ruby
项目地址: git://github.com/saab-simc-admin/palletjack.git
创建时间: 2016-07-20T11:34:47Z
项目社区:https://github.com/saab-simc-admin/palletjack

开源协议:MIT License

下载


Pallet Jack

Pallet Jack is a lightweight configuration management database, utilizing
the power of a Posix file system to store yaml serialized key-value trees.

A database is created from a warehouse (directory) of different kinds
(directory) of pallets (directory), each containing boxes (yaml files)
with keys. Pallets can contain other pallets, recursively, to form
hierarchical inheritance. Pallets can also contain references to other
pallets (symlinks) out of hierarchy, to build a Directed Acyclic Graph
of key-value search nodes.

The entire structure is indended to live beside configuration management
code and data in a version control system repository, to enable tagged
releases of both code, data and metadata.

The toplevel transforms.yaml file defines key-value transforms to perform
when loading the database, e.g. synthesize key-values from pallet metadata.

  1. warehouse
  2. ├── building
  3. └── 1
  4. └── location.yaml
  5. ├── chassis
  6. └── Example:FastServer-128:1234ABCD
  7. ├── identity.yaml
  8. ├── location.yaml
  9. └── rack -> ../../rack/1-A-2/
  10. ├── domain
  11. └── example.com
  12. ├── dns.yaml
  13. ├── ipv4_network -> ../../ipv4_network/192.168.0.0_24/
  14. └── services.yaml
  15. ├── ipv4_interface
  16. ├── 192.168.0.1
  17. ├── dns.yaml
  18. ├── domain -> ../../domain/example.com/
  19. ├── ipv4_network -> ../../ipv4_network/192.168.0.0_24/
  20. ├── phy_nic -> ../../phy_nic/14:18:77:ab:cd:ef/
  21. └── system -> ../../system/vmhost1/
  22. └── 192.168.0.2
  23. ├── domain -> ../../domain/example.com/
  24. ├── ipv4_network -> ../../ipv4_network/192.168.0.0_24/
  25. ├── phy_nic -> ../../phy_nic/52:54:00:12:34:56/
  26. └── system -> ../../system/testvm/
  27. ├── ipv4_network
  28. └── 192.168.0.0_24
  29. ├── dhcp.yaml
  30. └── identity.yaml
  31. ├── machine
  32. ├── testvm
  33. ├── host -> ../../system/vmhost1/
  34. └── type.yaml
  35. └── vmhost1
  36. ├── chassis -> ../../chassis/Example:FastServer-128:1234ABCD/
  37. └── type.yaml
  38. ├── netinstall
  39. └── CentOS-7.3.1611-x86_64
  40. ├── Kickstart_sda
  41. └── kickstart.yaml
  42. ├── Kickstart_vda
  43. └── kickstart.yaml
  44. ├── Manual
  45. └── kickstart.yaml
  46. └── os -> ../../os/CentOS-7.3.1611-x86_64
  47. ├── os
  48. └── CentOS-7.3.1611-x86_64
  49. └── kickstart.yaml
  50. ├── phy_nic
  51. ├── 14:18:77:ab:cd:ef
  52. ├── chassis -> ../../chassis/Example:FastServer-128:1234ABCD/
  53. └── location.yaml
  54. └── 52:54:00:12:34:56
  55. ├── identity.yaml
  56. └── phy_nic -> ../../phy_nic/14:18:77:ab:cd:ef/
  57. ├── rack
  58. └── 1-A-2
  59. ├── location.yaml
  60. └── room -> ../../room/server-room-1/
  61. ├── room
  62. └── server-room-1
  63. ├── building -> ../../building/1
  64. ├── identity.yaml
  65. └── location.yaml
  66. ├── service
  67. ├── dhcp-server
  68. ├── kea.yaml
  69. └── example-com
  70. └── kea.yaml
  71. └── dns-resolver
  72. └── example-com
  73. └── unbound.yaml
  74. ├── system
  75. ├── testvm
  76. ├── architecture.yaml
  77. ├── domain -> ../../domain/example.com/
  78. ├── machine -> ../../machine/testvm/
  79. ├── netinstall -> ../../netinstall/CentOS-7.3.1611-x86_64/Kickstart_vda/
  80. └── role.yaml
  81. └── vmhost1
  82. ├── architecture.yaml
  83. ├── domain -> ../../domain/example.com/
  84. ├── machine -> ../../machine/vmhost1/
  85. ├── netinstall -> ../../netinstall/CentOS-7.3.1611-x86_64/Kickstart_sda/
  86. └── role.yaml
  87. └── transforms.yaml
  1. % irb -r palletjack
  2. 2.3.1 :001 > jack = PalletJack.load('examples/warehouse')
  3. 2.3.1 :002 > testvm = jack.fetch(kind: 'system', name: 'testvm')
  4. 2.3.1 :003 > testvm['host.type']
  5. => "virtual"
  6. 2.3.1 :004 > jack.each(kind: 'system') {|pallet| puts "#{pallet['net.dns.name']}: #{pallet['chassis.serial']}" }
  7. vmhost1: 1234ABCD
  8. testvm: 1234ABCD
  9. 2.3.1 :005 > jack.each(kind: 'system', all?: {'host.type' => 'virtual'}) {|system| puts system['net.dns.name'] }
  10. testvm

Installation

Add this line to your application’s Gemfile:

  1. gem 'palletjack'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install palletjack

Creating warehouse objects

Warehouse objects are simple directories, so you can create them using
mkdir. To simplify the process, there are some tools that create
objects with standard links and YAML structures for you. Example:

  1. $ create_domain --warehouse /tmp/warehouse --domain example.com --network 192.168.42.0/24
  2. $ create_system --warehouse /tmp/warehouse --system vmhost --domain example.com --os CentOS-7.3.1611-x86_64
  3. $ create_ipv4_interface --warehouse /tmp/warehouse --system vmhost --domain example.com --mac 52:54:00:8d:be:fe --ipv4 192.168.42.1 --network 192.168.42.0/24
  4. $ dump_pallet --warehouse /tmp/warehouse --type ipv4_interface 192.168.42.1
  1. ---
  2. pallet:
  3. ipv4_network: 192.168.42.0_24
  4. boxes: []
  5. references:
  6. ipv4_network: 192.168.42.0_24
  7. domain: example.com
  8. phy_nic: 52:54:00:8d:be:fe
  9. os: CentOS-7.3.1611-x86_64
  10. system: vmhost
  11. domain: example.com
  12. phy_nic: 52:54:00:8d:be:fe
  13. os: CentOS-7.3.1611-x86_64
  14. system: vmhost
  15. ipv4_interface: 192.168.42.1
  16. net:
  17. dhcp:
  18. tftp-server: ''
  19. boot-file: ''
  20. ipv4:
  21. gateway: ''
  22. prefixlen: '24'
  23. cidr: 192.168.42.0/24
  24. address: 192.168.42.1
  25. dns:
  26. resolver:
  27. - ''
  28. ns:
  29. - ''
  30. soa-ns: ''
  31. soa-contact: ''
  32. domain: example.com
  33. name: vmhost
  34. fqdn: vmhost.example.com
  35. service:
  36. syslog:
  37. - address: syslog-archive.example.com
  38. port: 514
  39. protocol: udp
  40. - address: logstash.example.com
  41. port: 5514
  42. protocol: tcp
  43. layer2:
  44. name: ''
  45. address: 52:54:00:8d:be:fe
  46. host:
  47. kickstart:
  48. baseurl: http://mirror.centos.org/centos/7.3.1611/os/x86_64/
  49. pxelinux:
  50. kernel: "/boot/CentOS-7.3.1611-x86_64/vmlinuz"
  51. config: CentOS-7.3.1611-x86_64
  52. system:
  53. os: CentOS-7.3.1611-x86_64
  54. role:
  55. - ''
  56. name: vmhost

Development

After checking out the repo, run bin/setup to install
dependencies. Then, run rake spec to run the tests. You can also run
bin/console for an interactive prompt that will allow you to
experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

We are happy to accept contributions in the form of issues and pull requests on GitHub. Please follow these guidelines to make the experience as smooth as possible:

  • All development takes place in feature branches, with master only accepting non-fast-forward merges.

  • Others shall be able to use the Pallet Jack library to build their own tools. To facilitate this, the library and the included tools are packaged as two different Ruby gems, and are intended to be loosely coupled. If you introduce API changes, please increment version numbers according to semantic versioning.

  • All code will be reviewed before it is merged. To help the reviewer, send your work as a series of logically separate changes, not as one gigantic squash commit. Make sure bisection will work by ensuring the code actually works after each change.

  • GnuPG sign all your commits and tags, with a key that is validated by GitHub.

    • GitHub’s web UI cannot generate signed merges when accepting pull requests. Instead, we use a custom tool to accept them. You can still send them through the web as usual.

    • Your code shall be signed by you. Therefore, the maintainer cannot fix any merge conflicts arising from your pull request. If there are any conflicts, please rebase onto current master before sending your pull request.

  • Document your work.

    • At an absolute minimum, Ruby code shall have RDoc blocks documenting each function, with analogues for other languages (e.g. Python docstrings).

    • User-visible features shall have examples in the examples/ directory. In particular, the example warehouse shall include demonstrations of all keys used by any included tool.

      • If your code needs larger chunks of static data to work, please provide it in a separate directory under examples/. See e.g. the examples/pxelinux/ tree, which contains files required to make sense of the output from palletjack2pxelinux.
    • Write your commit messages in the usual Git style: a short summary in the first line, then paragraphs of explanatory text, line wrapped.

    • For externally visible changes (either to users or tool developers), add a note in the changelog.

  • Test your code.

    • Code shall pass Rubocop tests. See .rubocop.yml for configured options. Rubocop is automaticallly run with the default Rake task.

    • Tests shall be written in RSpec.

    • Library code shall have unit tests.

    • Tools shall have integration and end-to-end tests.