lex-chef 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fb7d5d2436d06aaf401b10b870302e26129ef8e9252f1b47d7ed97cd9126e341
4
+ data.tar.gz: 6f4167c584b84b0ac68dafd0fde32d2874e4b5a36c42415a27af356b9e5c5f05
5
+ SHA512:
6
+ metadata.gz: 7ca6fb291fc9b7d96ef84a780ea9d4d762a9790de89b6f5775cdf8c09ac4ff0dc8c5d9288382f681df9a25ad3bd81b913986d02ec9c43ff74f8c823ee1ee5156
7
+ data.tar.gz: ffc638de7b3074eb952be4ed3c88116df771640264b696950c715be205dd577f1216d6f2982a9738ba525d3adc921218477a7e3fe1bee5a82bf7f164d6aee4af
@@ -0,0 +1,16 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+
7
+ jobs:
8
+ ci:
9
+ uses: LegionIO/.github/.github/workflows/ci.yml@main
10
+
11
+ release:
12
+ needs: ci
13
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
14
+ uses: LegionIO/.github/.github/workflows/release.yml@main
15
+ secrets:
16
+ rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,48 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.4
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Layout/LineLength:
7
+ Max: 160
8
+
9
+ Layout/SpaceAroundEqualsInParameterDefault:
10
+ EnforcedStyle: space
11
+
12
+ Layout/HashAlignment:
13
+ EnforcedHashRocketStyle: table
14
+ EnforcedColonStyle: table
15
+
16
+ Metrics/MethodLength:
17
+ Max: 50
18
+
19
+ Metrics/ClassLength:
20
+ Max: 1500
21
+
22
+ Metrics/ModuleLength:
23
+ Max: 1500
24
+
25
+ Metrics/BlockLength:
26
+ Max: 40
27
+
28
+ Metrics/AbcSize:
29
+ Max: 60
30
+
31
+ Metrics/CyclomaticComplexity:
32
+ Max: 15
33
+
34
+ Metrics/PerceivedComplexity:
35
+ Max: 17
36
+
37
+ Style/Documentation:
38
+ Enabled: false
39
+
40
+ Style/SymbolArray:
41
+ Enabled: true
42
+
43
+ Style/FrozenStringLiteralComment:
44
+ Enabled: true
45
+ EnforcedStyle: always
46
+
47
+ Naming/FileName:
48
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.2.0] - 2026-03-15
6
+
7
+ ### Added
8
+ - `Helpers::Client` module with Faraday connection factory (supports `url:`, `client_name:`, `api_key:`)
9
+ - `Runners::Node` - full CRUD: `list_nodes`, `get_node`, `create_node`, `update_node`, `delete_node`
10
+ - `Runners::Organization` - full CRUD: `list_organizations`, `get_organization`, `create_organization`, `update_organization`, `delete_organization`
11
+ - `Runners::Cookbook` - `list_cookbooks`, `get_cookbook`
12
+ - `Runners::Environment` - `list_environments`, `get_environment`, `create_environment`, `delete_environment`
13
+ - `Runners::Role` - `list_roles`, `get_role`, `create_role`, `delete_role`
14
+ - `Runners::Group` - `list_groups`, `get_group`
15
+ - `Runners::Policy` - `list_policies`, `get_policy`
16
+ - `Runners::Data` - `list_data_bags`, `get_data_bag`
17
+ - `Runners::License` - `get_license`
18
+ - `Runners::User` - `list_users`, `get_user`
19
+ - `Runners::Search` - `search` with `index:`, `query:`, `rows:`, `start:` parameters
20
+ - Standalone `Client` class including all runners for use outside the Legion runtime
21
+ - Entry point now requires all runner and helper modules
22
+
23
+ ## [0.1.0] - 2026-03-13
24
+
25
+ ### Added
26
+ - Initial release
data/CLAUDE.md ADDED
@@ -0,0 +1,69 @@
1
+ # lex-chef: Chef Server Integration for LegionIO
2
+
3
+ **Repository Level 3 Documentation**
4
+ - **Parent**: `/Users/miverso2/rubymine/legion/extensions-other/CLAUDE.md`
5
+ - **Grandparent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
6
+
7
+ ## Purpose
8
+
9
+ Legion Extension that connects to Chef Server APIs via Faraday. Defines runners for querying and managing Chef resources including nodes, cookbooks, environments, roles, groups, policies, data bags, licenses, organizations, users, and search.
10
+
11
+ **Version**: 0.2.0
12
+ **GitHub**: https://github.com/LegionIO/lex-chef
13
+ **License**: MIT
14
+
15
+ ## Status
16
+
17
+ Implemented (v0.2.0). `Helpers::Client` wired up with Faraday and Chef Server auth headers. `Node` and `Organization` runners fully implemented with CRUD. Remaining 9 runners have `list` and `get` stubs. Standalone `Client` class includes all 12 runners.
18
+
19
+ ## Architecture
20
+
21
+ ```
22
+ Legion::Extensions::Chef
23
+ ├── Runners/
24
+ │ ├── Node # list_nodes, get_node, create_node, update_node, delete_node (full CRUD)
25
+ │ ├── Organization # list_orgs, get_org, create_org, update_org, delete_org (full CRUD)
26
+ │ ├── Cookbook # list, get stubs
27
+ │ ├── Environment # list, get stubs
28
+ │ ├── Role # list, get stubs
29
+ │ ├── Group # list, get stubs
30
+ │ ├── Policy # list, get stubs
31
+ │ ├── Data # list, get stubs
32
+ │ ├── License # list, get stubs
33
+ │ ├── User # list, get stubs
34
+ │ ├── Search # list, get stubs
35
+ │ └── [1 additional runner] # list, get stubs
36
+ ├── Helpers/
37
+ │ └── Client # Faraday connection with Chef Server auth headers
38
+ └── Client # Standalone client class (includes all 12 runners)
39
+ ```
40
+
41
+ ## Key Files
42
+
43
+ | Path | Purpose |
44
+ |------|---------|
45
+ | `lib/legion/extensions/chef.rb` | Entry point, extension registration |
46
+ | `lib/legion/extensions/chef/runners/` | All Chef resource runners |
47
+ | `lib/legion/extensions/chef/helpers/client.rb` | Faraday client with Chef Server auth headers |
48
+ | `lib/legion/extensions/chef/client.rb` | Standalone `Client` class for use outside Legion framework |
49
+ | `lib/legion/extensions/chef/version.rb` | Version constant (0.2.0) |
50
+
51
+ ## Dependencies
52
+
53
+ | Gem | Purpose |
54
+ |-----|---------|
55
+ | `faraday` (>= 2.0) | HTTP client for Chef Server API |
56
+
57
+ ## Development
58
+
59
+ 14 specs total.
60
+
61
+ ```bash
62
+ bundle install
63
+ bundle exec rspec
64
+ bundle exec rubocop
65
+ ```
66
+
67
+ ---
68
+
69
+ **Maintained By**: Matthew Iverson (@Esity)
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+ gem 'bundler', '>= 2'
7
+ gem 'rake'
8
+ gem 'rspec', '~> 3.0'
9
+ gem 'rubocop'
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lex-chef (0.2.0)
5
+ faraday (>= 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.9)
11
+ public_suffix (>= 2.0.2, < 8.0)
12
+ ast (2.4.3)
13
+ bigdecimal (4.0.1)
14
+ diff-lcs (1.6.2)
15
+ faraday (2.14.1)
16
+ faraday-net_http (>= 2.0, < 3.5)
17
+ json
18
+ logger
19
+ faraday-net_http (3.4.2)
20
+ net-http (~> 0.5)
21
+ json (2.19.1)
22
+ json-schema (6.2.0)
23
+ addressable (~> 2.8)
24
+ bigdecimal (>= 3.1, < 5)
25
+ language_server-protocol (3.17.0.5)
26
+ lint_roller (1.1.0)
27
+ logger (1.7.0)
28
+ mcp (0.8.0)
29
+ json-schema (>= 4.1)
30
+ net-http (0.9.1)
31
+ uri (>= 0.11.1)
32
+ parallel (1.27.0)
33
+ parser (3.3.10.2)
34
+ ast (~> 2.4.1)
35
+ racc
36
+ prism (1.9.0)
37
+ public_suffix (7.0.5)
38
+ racc (1.8.1)
39
+ rainbow (3.1.1)
40
+ rake (13.3.1)
41
+ regexp_parser (2.11.3)
42
+ rspec (3.13.2)
43
+ rspec-core (~> 3.13.0)
44
+ rspec-expectations (~> 3.13.0)
45
+ rspec-mocks (~> 3.13.0)
46
+ rspec-core (3.13.6)
47
+ rspec-support (~> 3.13.0)
48
+ rspec-expectations (3.13.5)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.13.0)
51
+ rspec-mocks (3.13.8)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.13.0)
54
+ rspec-support (3.13.7)
55
+ rubocop (1.85.1)
56
+ json (~> 2.3)
57
+ language_server-protocol (~> 3.17.0.2)
58
+ lint_roller (~> 1.1.0)
59
+ mcp (~> 0.6)
60
+ parallel (~> 1.10)
61
+ parser (>= 3.3.0.2)
62
+ rainbow (>= 2.2.2, < 4.0)
63
+ regexp_parser (>= 2.9.3, < 3.0)
64
+ rubocop-ast (>= 1.49.0, < 2.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 2.4.0, < 4.0)
67
+ rubocop-ast (1.49.1)
68
+ parser (>= 3.3.7.2)
69
+ prism (~> 1.7)
70
+ ruby-progressbar (1.13.0)
71
+ unicode-display_width (3.2.0)
72
+ unicode-emoji (~> 4.1)
73
+ unicode-emoji (4.2.0)
74
+ uri (1.1.1)
75
+
76
+ PLATFORMS
77
+ arm64-darwin-25
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ bundler (>= 2)
82
+ lex-chef!
83
+ rake
84
+ rspec (~> 3.0)
85
+ rubocop
86
+
87
+ BUNDLED WITH
88
+ 2.6.9
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Esity
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # lex-chef
2
+
3
+ Chef Server integration for [LegionIO](https://github.com/LegionIO/LegionIO). Query and manage Chef resources including nodes, organizations, cookbooks, environments, roles, and more via the Chef Server API from within task chains or as a standalone client library.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ gem install lex-chef
9
+ ```
10
+
11
+ Or add to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'lex-chef'
15
+ ```
16
+
17
+ ## Standalone Usage
18
+
19
+ ```ruby
20
+ require 'legion/extensions/chef'
21
+
22
+ client = Legion::Extensions::Chef::Client.new(
23
+ host: 'https://chef.example.com',
24
+ token: 'your-api-token'
25
+ )
26
+
27
+ # Nodes (full CRUD)
28
+ client.list_nodes
29
+ client.get_node(node: 'web-01')
30
+ client.create_node(node: 'web-02', attributes: {})
31
+ client.update_node(node: 'web-02', attributes: { role: 'web' })
32
+ client.delete_node(node: 'web-02')
33
+
34
+ # Organizations (full CRUD)
35
+ client.list_orgs
36
+ client.get_org(org: 'my-org')
37
+ client.create_org(org: 'new-org', full_name: 'New Org')
38
+ client.update_org(org: 'new-org', full_name: 'Updated Org')
39
+ client.delete_org(org: 'new-org')
40
+
41
+ # Other runners (list and get)
42
+ client.list_cookbooks
43
+ client.get_cookbook(cookbook: 'nginx')
44
+ ```
45
+
46
+ ## Runners
47
+
48
+ ### Node (full CRUD)
49
+
50
+ | Method | Parameters | Description |
51
+ |--------|-----------|-------------|
52
+ | `list_nodes` | (none) | List all nodes |
53
+ | `get_node` | `node:` | Get a node |
54
+ | `create_node` | `node:`, `attributes:` | Create a node |
55
+ | `update_node` | `node:`, `attributes:` | Update a node |
56
+ | `delete_node` | `node:` | Delete a node |
57
+
58
+ ### Organization (full CRUD)
59
+
60
+ | Method | Parameters | Description |
61
+ |--------|-----------|-------------|
62
+ | `list_orgs` | (none) | List all organizations |
63
+ | `get_org` | `org:` | Get an organization |
64
+ | `create_org` | `org:`, `full_name:` | Create an organization |
65
+ | `update_org` | `org:`, `full_name:` | Update an organization |
66
+ | `delete_org` | `org:` | Delete an organization |
67
+
68
+ ### Additional Runners (list and get only)
69
+
70
+ The following runners have `list` and `get` implemented. `create`, `update`, and `delete` are pending.
71
+
72
+ | Runner | Methods |
73
+ |--------|---------|
74
+ | Cookbook | `list_cookbooks`, `get_cookbook` |
75
+ | Environment | `list_environments`, `get_environment` |
76
+ | Role | `list_roles`, `get_role` |
77
+ | Group | `list_groups`, `get_group` |
78
+ | Policy | `list_policies`, `get_policy` |
79
+ | Data | `list_data_bags`, `get_data_bag` |
80
+ | License | `list_licenses`, `get_license` |
81
+ | User | `list_users`, `get_user` |
82
+ | Search | `list_search_indexes`, `get_search_index` |
83
+
84
+ ## Requirements
85
+
86
+ - Ruby >= 3.4
87
+ - Chef Server with API token (Bearer token auth)
88
+ - `faraday` >= 2.0
89
+
90
+ ## License
91
+
92
+ MIT
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/lex-chef.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/legion/extensions/chef/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'lex-chef'
7
+ spec.version = Legion::Extensions::Chef::VERSION
8
+ spec.authors = ['Esity']
9
+ spec.email = ['matthewdiverson@gmail.com']
10
+
11
+ spec.summary = 'LEX::Chef'
12
+ spec.description = 'LEX::Chef'
13
+ spec.homepage = 'https://github.com/LegionIO/lex-chef'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.4'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-chef'
19
+ spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-chef'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-chef'
21
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-chef/issues'
22
+ spec.metadata['rubygems_mfa_required'] = 'true'
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_dependency 'faraday', '>= 2.0'
29
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers/client'
4
+ require_relative 'runners/node'
5
+ require_relative 'runners/organization'
6
+ require_relative 'runners/cookbook'
7
+ require_relative 'runners/environment'
8
+ require_relative 'runners/role'
9
+ require_relative 'runners/group'
10
+ require_relative 'runners/policy'
11
+ require_relative 'runners/data'
12
+ require_relative 'runners/license'
13
+ require_relative 'runners/user'
14
+ require_relative 'runners/search'
15
+
16
+ module Legion
17
+ module Extensions
18
+ module Chef
19
+ class Client
20
+ include Helpers::Client
21
+ include Runners::Node
22
+ include Runners::Organization
23
+ include Runners::Cookbook
24
+ include Runners::Environment
25
+ include Runners::Role
26
+ include Runners::Group
27
+ include Runners::Policy
28
+ include Runners::Data
29
+ include Runners::License
30
+ include Runners::User
31
+ include Runners::Search
32
+
33
+ attr_reader :opts
34
+
35
+ def initialize(url: 'https://localhost/organizations/default', client_name: nil, api_key: nil, **extra)
36
+ @opts = { url: url, client_name: client_name, api_key: api_key, **extra }.compact
37
+ end
38
+
39
+ def connection(**override)
40
+ super(**@opts, **override)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Chef
8
+ module Helpers
9
+ module Client
10
+ def connection(url: 'https://localhost/organizations/default', client_name: nil, api_key: nil, **)
11
+ Faraday.new(url: url) do |conn|
12
+ conn.request :json
13
+ conn.response :json, content_type: /\bjson$/
14
+ conn.headers['X-Chef-Version'] = '18.0'
15
+ conn.headers['X-Ops-UserId'] = client_name if client_name
16
+ conn.headers['Authorization'] = "Bearer #{api_key}" if api_key
17
+ conn.headers['Accept'] = 'application/json'
18
+ conn.adapter Faraday.default_adapter
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Cookbook
8
+ def list_cookbooks(**)
9
+ { cookbooks: connection(**).get('cookbooks').body }
10
+ end
11
+
12
+ def get_cookbook(name:, **)
13
+ { cookbook: connection(**).get("cookbooks/#{name}").body }
14
+ end
15
+
16
+ include Legion::Extensions::Helpers::Lex
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Data
8
+ def list_data_bags(**)
9
+ { data_bags: connection(**).get('data').body }
10
+ end
11
+
12
+ def get_data_bag(name:, **)
13
+ { data_bag: connection(**).get("data/#{name}").body }
14
+ end
15
+
16
+ include Legion::Extensions::Helpers::Lex
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Environment
8
+ def list_environments(**)
9
+ { environments: connection(**).get('environments').body }
10
+ end
11
+
12
+ def get_environment(name:, **)
13
+ { environment: connection(**).get("environments/#{name}").body }
14
+ end
15
+
16
+ def create_environment(name:, **)
17
+ resp = connection(**).post('environments', { name: name })
18
+ { created: true, environment: resp.body }
19
+ end
20
+
21
+ def delete_environment(name:, **)
22
+ { deleted: true, environment: connection(**).delete("environments/#{name}").body }
23
+ end
24
+
25
+ include Legion::Extensions::Helpers::Lex
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Group
8
+ def list_groups(**)
9
+ { groups: connection(**).get('groups').body }
10
+ end
11
+
12
+ def get_group(name:, **)
13
+ { group: connection(**).get("groups/#{name}").body }
14
+ end
15
+
16
+ include Legion::Extensions::Helpers::Lex
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module License
8
+ def get_license(**)
9
+ { license: connection(**).get('license').body }
10
+ end
11
+
12
+ include Legion::Extensions::Helpers::Lex
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Node
8
+ def list_nodes(**)
9
+ resp = connection(**).get('nodes')
10
+ { nodes: resp.body }
11
+ end
12
+
13
+ def get_node(name:, **)
14
+ resp = connection(**).get("nodes/#{name}")
15
+ { node: resp.body }
16
+ end
17
+
18
+ def create_node(name:, run_list: [], **opts)
19
+ body = { name: name, run_list: run_list }
20
+ body[:automatic] = opts[:automatic] if opts[:automatic]
21
+ body[:default] = opts[:default_attrs] if opts[:default_attrs]
22
+ resp = connection(**opts).post('nodes', body)
23
+ { created: true, node: resp.body }
24
+ end
25
+
26
+ def update_node(name:, **opts)
27
+ body = {}
28
+ body[:run_list] = opts[:run_list] if opts[:run_list]
29
+ body[:automatic] = opts[:automatic] if opts[:automatic]
30
+ resp = connection(**opts).put("nodes/#{name}", body)
31
+ { updated: true, node: resp.body }
32
+ end
33
+
34
+ def delete_node(name:, **)
35
+ resp = connection(**).delete("nodes/#{name}")
36
+ { deleted: true, node: resp.body }
37
+ end
38
+
39
+ include Legion::Extensions::Helpers::Lex
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Organization
8
+ # https://docs.chef.io/api_chef_server/#organizations
9
+ def list_organizations(**)
10
+ resp = connection(**).get('/organizations')
11
+ { organizations: resp.body }
12
+ end
13
+
14
+ def get_organization(name:, **)
15
+ resp = connection(**).get("/organizations/#{name}")
16
+ { organization: resp.body }
17
+ end
18
+
19
+ def create_organization(name:, full_name:, **)
20
+ resp = connection(**).post('/organizations', { name: name, full_name: full_name })
21
+ { created: true, organization: resp.body }
22
+ end
23
+
24
+ def update_organization(name:, full_name:, **)
25
+ resp = connection(**).put("/organizations/#{name}", { full_name: full_name })
26
+ { updated: true, organization: resp.body }
27
+ end
28
+
29
+ def delete_organization(name:, **)
30
+ resp = connection(**).delete("/organizations/#{name}")
31
+ { deleted: true, organization: resp.body }
32
+ end
33
+
34
+ include Legion::Extensions::Helpers::Lex
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Policy
8
+ def list_policies(**)
9
+ { policies: connection(**).get('policies').body }
10
+ end
11
+
12
+ def get_policy(name:, **)
13
+ { policy: connection(**).get("policies/#{name}").body }
14
+ end
15
+
16
+ include Legion::Extensions::Helpers::Lex
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Role
8
+ def list_roles(**)
9
+ { roles: connection(**).get('roles').body }
10
+ end
11
+
12
+ def get_role(name:, **)
13
+ { role: connection(**).get("roles/#{name}").body }
14
+ end
15
+
16
+ def create_role(name:, run_list: [], **)
17
+ resp = connection(**).post('roles', { name: name, run_list: run_list })
18
+ { created: true, role: resp.body }
19
+ end
20
+
21
+ def delete_role(name:, **)
22
+ { deleted: true, role: connection(**).delete("roles/#{name}").body }
23
+ end
24
+
25
+ include Legion::Extensions::Helpers::Lex
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module Search
8
+ def search(index:, query: '*:*', rows: 1000, start: 0, **)
9
+ resp = connection(**).get("search/#{index}", { q: query, rows: rows, start: start })
10
+ { total: resp.body['total'], rows: resp.body['rows'] }
11
+ end
12
+
13
+ include Legion::Extensions::Helpers::Lex
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ module Runners
7
+ module User
8
+ def list_users(**)
9
+ { users: connection(**).get('users').body }
10
+ end
11
+
12
+ def get_user(name:, **)
13
+ { user: connection(**).get("users/#{name}").body }
14
+ end
15
+
16
+ include Legion::Extensions::Helpers::Lex
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Chef
6
+ VERSION = '0.2.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'legion/extensions/chef/version'
4
+ require 'legion/extensions/chef/helpers/client'
5
+ require 'legion/extensions/chef/runners/node'
6
+ require 'legion/extensions/chef/runners/organization'
7
+ require 'legion/extensions/chef/runners/cookbook'
8
+ require 'legion/extensions/chef/runners/environment'
9
+ require 'legion/extensions/chef/runners/role'
10
+ require 'legion/extensions/chef/runners/group'
11
+ require 'legion/extensions/chef/runners/policy'
12
+ require 'legion/extensions/chef/runners/data'
13
+ require 'legion/extensions/chef/runners/license'
14
+ require 'legion/extensions/chef/runners/user'
15
+ require 'legion/extensions/chef/runners/search'
16
+
17
+ module Legion
18
+ module Extensions
19
+ module Chef
20
+ extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lex-chef
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Esity
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: faraday
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '2.0'
26
+ description: LEX::Chef
27
+ email:
28
+ - matthewdiverson@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".github/workflows/ci.yml"
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - CHANGELOG.md
38
+ - CLAUDE.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - lex-chef.gemspec
45
+ - lib/legion/extensions/chef.rb
46
+ - lib/legion/extensions/chef/client.rb
47
+ - lib/legion/extensions/chef/helpers/client.rb
48
+ - lib/legion/extensions/chef/runners/cookbook.rb
49
+ - lib/legion/extensions/chef/runners/data.rb
50
+ - lib/legion/extensions/chef/runners/environment.rb
51
+ - lib/legion/extensions/chef/runners/group.rb
52
+ - lib/legion/extensions/chef/runners/license.rb
53
+ - lib/legion/extensions/chef/runners/node.rb
54
+ - lib/legion/extensions/chef/runners/organization.rb
55
+ - lib/legion/extensions/chef/runners/policy.rb
56
+ - lib/legion/extensions/chef/runners/role.rb
57
+ - lib/legion/extensions/chef/runners/search.rb
58
+ - lib/legion/extensions/chef/runners/user.rb
59
+ - lib/legion/extensions/chef/version.rb
60
+ homepage: https://github.com/LegionIO/lex-chef
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ homepage_uri: https://github.com/LegionIO/lex-chef
65
+ source_code_uri: https://github.com/LegionIO/lex-chef
66
+ documentation_uri: https://github.com/LegionIO/lex-chef
67
+ changelog_uri: https://github.com/LegionIO/lex-chef
68
+ bug_tracker_uri: https://github.com/LegionIO/lex-chef/issues
69
+ rubygems_mfa_required: 'true'
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '3.4'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.6.9
85
+ specification_version: 4
86
+ summary: LEX::Chef
87
+ test_files: []