Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFINSPEC-68 Adds target_id in the reporter. #5895

Merged
merged 6 commits into from
Mar 10, 2022

Conversation

Vasu1105
Copy link
Contributor

@Vasu1105 Vasu1105 commented Mar 3, 2022

Signed-off-by: Vasu1105 vasundhara.jagdale@chef.io

Description

This adds the target_id in the reporter which is nothing but the UUID generated by train to uniquely identify the target system/node.

The json_automate data looks like this after integrating target_id in the reporter.

{"platform":{"name":"ubuntu","release":"20.04","target_id":"8c32a7d2-1813-45c1-b061-8cr73482374832"},"profiles":[{"name":"profile_c","version":"0.1.0","sha256":"9da7ef2e4364d926df8f1ce31b213169e6b8d9bc44342342456fb9d70","title":"InSpec Profile","maintainer":"The Authors","summary":"An InSpec Compliance Profile","license":"Apache-2.0","copyright":"The Authors","copyright_email":"you@example.com","supports":[{"platform":"os"}],"attributes":[],"groups":[{"id":"controls/example.rb","controls":["(generated from example.rb:6 e190087561fd3ce1d87d50831d4fbe70)","tmp-1.3"],"title":"sample section"}],"controls":[{"id":"(generated from example.rb:6 e190087561fd3ce1d87d50831d4fbe70)","title":null,"desc":null,"descriptions":[],"impact":0.5,"refs":[],"tags":{},"code":"","source_location":{"line":92,"ref":"/Users/vjagdale/workspace/inspec-ruby-3/inspec/lib/inspec/control_eval_context.rb"},"waiver_data":{},"results":[{"status":"passed","code_desc":"File /tmp is expected to be directory","run_time":0.869684,"start_time":"2022-03-03T15:02:48+05:30","resource_class":"file","resource_params":"[\"/tmp\"]"}]},{"id":"tmp-1.3","title":"Create /tmp directory","desc":"An optional description...","descriptions":[{"label":"default","data":"An optional description..."}],"impact":0.7,"refs":[],"tags":{},"code":"control \"tmp-1.3\" do                        # A unique ID for this control\n  impact 0.7                                # The criticality, if this control fails.\n  title \"Create /tmp directory\"             # A human-readable title\n  desc \"An optional description...\"\n  describe file(\"/tmp\") do                  # The actual test\n    it { should be_directory }\n  end\nend\n","source_location":{"line":11,"ref":"/Users/vjagdale/workspace/test-profiles/profile_c/controls/example.rb"},"waiver_data":{},"results":[{"status":"passed","code_desc":"File /tmp is expected to be directory","run_time":0.005681,"start_time":"2022-03-03T15:02:49+05:30","resource_class":"file","resource_params":"[\"/tmp\"]"}]}],"status":"loaded","status_message":""}],"statistics":{"duration":0.877116},"version":"5.1.3"}

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New content (non-breaking change)
  • Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • I have read the CONTRIBUTING document.

@Vasu1105 Vasu1105 requested a review from a team as a code owner March 3, 2022 10:33
@netlify
Copy link

netlify bot commented Mar 3, 2022

✔️ Deploy Preview for chef-inspec ready!

🔨 Explore the source changes: 30ef964

🔍 Inspect the deploy log: https://app.netlify.com/sites/chef-inspec/deploys/622a161f6f346c0009a4669e

😎 Browse the preview: https://deploy-preview-5895--chef-inspec.netlify.app

@Vasu1105 Vasu1105 self-assigned this Mar 3, 2022
@Vasu1105 Vasu1105 force-pushed the vasundhara/support-generating-target-id branch 2 times, most recently from 18e690b to 8b42d01 Compare March 7, 2022 11:12
@aaronlippold
Copy link
Collaborator

What do you think about maybe calling this target_uuid for clarity rather than ID. ID could mean a lot of things.

@Vasu1105
Copy link
Contributor Author

Vasu1105 commented Mar 7, 2022

What do you think about maybe calling this target_uuid for clarity rather than ID. ID could mean a lot of things.

We want to keep it as target_id it refers to the unique id of the target. @clintoncwolfe any thoughts on this?

@clintoncwolfe
Copy link
Contributor

The internal Chef term for this in Automate is target_id.

@aaronlippold
Copy link
Collaborator

Roger that.

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
…generates blank string on Windows due to which it fails

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
@Vasu1105 Vasu1105 force-pushed the vasundhara/support-generating-target-id branch from a48eb37 to 30ef964 Compare March 10, 2022 15:15
@clintoncwolfe clintoncwolfe merged commit 17c6010 into main Mar 10, 2022
@clintoncwolfe clintoncwolfe deleted the vasundhara/support-generating-target-id branch March 10, 2022 19:15
@Vasu1105 Vasu1105 changed the title [W.I.P] CFINSPEC-68 Adds target_id in the reporter. CFINSPEC-68 Adds target_id in the reporter. Mar 10, 2022
@jLemmings
Copy link

So the ability to pass an unique value to the test has been removed?

The docs still state: "--target-id=TARGET_ID Provide a ID which will be included on reports."

Back in 2018 the feature was added to pass an own identifier and now its gone? #3319

Would be great to have a clarification on how to set an own target_id.

@clintoncwolfe
Copy link
Contributor

Yes, we are reverting to the behavior in which the target id is always generated.
We have a pending update to the docs which will mark the --target-id option as deprecated. Should be posted in the next day or two.
Could you describe your use case in which you need to manually set the target id?

@jLemmings
Copy link

We run all Inspec tests using an Ansible Playbook. Lets say I would like to test all servers connected to product "A". I would then pass '--target-id=A-HOSTS' to the playbook so it would iterate over the Ansible Inventory which servers belong to the product "A". Each host would then resolve its hostname and add this as the target_id.

Would it not be better if the default would be a generated UUID. If the --target-id is passed then the target_id is not generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants