How to get reports of a puppet node using puppetdb api? - puppet

How do I get reports from a puppet node using puppetdb report api?

After playing around with the query parameters, it seems like following will do the work:
curl -X GET puppet.foo.com:8180/pdb/query/v4/reports -d 'limit=1' -d 'query=["=", "certname", "node.foo.com"]'

Related

Updating a file for a quick-pull using github cli

Currently in the github UI, a user can edit a file and create a new branch in a single action. This can also be done through the github api using something like this:
curl 'https://github.com/<my_org>/<my_repo>/tree-save/master/<path_to_file>' \
-H 'content-type: application/x-www-form-urlencoded' \
--data-raw 'authenticity_token=<generated_token>&filename=<filename>&new_filename=<filename>&content_changed=true&value=<new_contents_of_file>&message=Updated+file+in+my+repo&placeholder_message=Update+<filename>&description=&commit-choice=quick-pull&target_branch=<new_branch_name>&quick_pull=master&guidance_task=&commit=<target_commit_checksum>&same_repo=1&pr='
What I would like to be able to do, is perform the same action using the github cli* (gh). I have tried using the following commands:
gh api <my_org>/<my_repo>/tree-save/master/<path_to_file> -F "filename=<filename>" -F ...
and
gh api repos/<my_org>/<my_repo>/contents/<path_to_file> -F "filename=<filename>" -F ...
For both cases (and many variations on these options), I'm getting a 404** back. Any ideas what I'm doing wrong? Does the github cli even allow the functionality allowed in the above curl?
* For those curious, I want to use the CLI because of how it handles auth and it's statelessness. I can't generate a token to use, like in the curl above. And, due to multiple issues, I also can't clone the repo locally.
** I'm able to retrieve the file just fine using the simple GET command (the second command above without the '-F' flags)
After reading documentation, and then verifying by altering credentials, it appears to be a permissions issue. Evidently, for security reasons, if a token is used that does not meet the required permissions, a 404 is returned instead of a 403.
Interesting that I can still use the curl above through the browser. So, now i need to figure out why the gh cli token does not have the same permissions as my user.

GitLab: Unauthorized access to API from pipeline using CI_JOB_TOKEN [duplicate]

This question already has answers here:
'Including' private project file using `$CI_JOB_TOKEN`
(2 answers)
Closed 3 years ago.
I am trying to make a request to the api of my gitlab host to resolve a tag release information, from what i have seen on the internet is that i could be able to get this information with curl using the pre-defined variables in the job so i could get what i am looking for.
Right now how the curl is being executed is like this:
curl -H "PRIVATE-TOKEN: $CI_JOB_TOKEN" $CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/tags/$CI_COMMIT_TAG
The response of this request is 404: Unauthorized. I have also tried using CI_BUILD_TOKEN environment variable but i also get the same result.
The repository on which i am creating these jobs is not a private, just internal. So i don't know how to make this work.
In case it's necessary, here's how the job pipeline is coded:
fetch-tag-info:
stage: setup
only:
- tags
image: ubuntu:18.04
before_script:
- apt-get update
- apt-get install curl jq -y
script:
- "curl -H \"PRIVATE-TOKEN: $CI_JOB_TOKEN\" $CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/tags/$CI_COMMIT_TAG -o release-notes.json"
You can use CI_JOB_TOKEN only in public project with everyone has access. See open issue in GitLab: https://gitlab.com/gitlab-org/gitlab-foss/issues/29566
Meanwhile, you can use the solution mentioned here: https://stackoverflow.com/a/44469417/6076269, or here: https://stackoverflow.com/a/51005977/6076269

GitLab API - Unable to access file which is within a directory

I have a GitLab project which is set up as follows:
myserver.com/SuperGroup/SubGroup/SubGroupProject
The tree of the following project is a top-level txt file and a txt file within a directory. I get the tree from the GitLab API with:
myserver.com/api/v4/projects/1/repository/tree?recursive=true
[{"id":"aba61143388f605d3fe9de9033ecb4575e4d9b69","name":"myDirectory","type":"tree","path":"myDirectory","mode":"040000"},{"id":"0e3a2b246ab92abac101d0eb2e96b57e2d24915d","name":"1stLevelFile.txt","type":"blob","path":"myDirectory/1stLevelFile.txt","mode":"100644"},{"id":"3501682ba833c3e50addab55e42488e98200b323","name":"top_level.txt","type":"blob","path":"top_level.txt","mode":"100644"}]
If I request the contents for top_level.txt they are returned without any issue via:
myserver.com/api/v4/projects/1/repository/files/top_level.txt?ref=master
However I am unable to access myDirectory/1stLevelFile.txt with any API call I try. E.g.:
myserver.com/api/v4/projects/1/repository/files/"myDirectory%2F1stLevelFile.txt"?ref=master
and,
myserver.com/api/v4/projects/1/repository/files/"myDirectory%2F1stLevelFile%2Etxt"?ref=master
Results in:
Not Found The requested URL /api/v4/projects/1/repository/files/myDirectory/1stLevelFile.txt was not found on this server.
Apache/2.4.25 (Debian) Server at myserver.com Port 443
myserver.com/api/v4/projects/1/repository/files/"myDirectory/1stLevelFile.txt"?ref=master and,
myserver.com/api/v4/projects/1/repository/files?ref=master&path=myDirectory%2F1stLevelFile.txt
Results in:
error "404 Not Found"
The versions of the components are:
GitLab 10.6.3-ee
GitLab Shell 6.0.4
GitLab Workhorse v4.0.0
GitLab API v4
Ruby 2.3.6p384
Rails 4.2.10
postgresql 9.6.8
According to my research there was a similar bug which was fixed with the 10.0.0 update.
I also added my ssh-key although I doubt it has any effect, following this advice with the same issue in php.
Solution:
I eventually solved it by adjusting the apache installed on the server.
Just follow these instructions: https://gitlab.com/gitlab-org/gitlab-ce/issues/35079#note_76374269
According to your code, I will go thinking you use curl.
If it is the case, why are you adding double quotes to your file path ?
The doc do not contains it.
Can you test it like that please ?
curl --request GET --header 'PRIVATE-TOKEN: XXXXXXXXX' myserver.com/api/v4/projects/1/repository/files/myDirectory%2F1stLevelFile%2Etxt?ref=master

How to get status of Spark jobs on YARN using REST API?

A spark application can run many jobs. My spark is running on yarn. Version 2.2.0.
How to get job running status and other info for a given application id, possibly using REST API?
job like follows:
enter image description here
This might be late but putting it for convenience. Hope it helps. You can use below Rest API command to get the status of any jobs running on YARN.
curl --negotiate -s -u : -X GET 'http://resourcemanagerhost:8088/ws/v1/cluster/apps/application_121766109986_12343/state'
O/P - {"state":"RUNNING"}
Throughout the job cycle the state will vary from NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED
You can use jq for a formatted output.
curl --negotiate -s -u : -X GET 'http://resourcemanagerhost:8088/ws/v1/cluster/apps/application_121766109986_12343'| jq .app.state
O/P - "RUNNING"
YARN has a Cluster Applications API. This shows the state along with other information. To use it:
$ curl 'RMURL/ws/v1/cluster/apps/APP_ID'
with your application id as APP_ID.
It provides:

SSRS Migration Sharepoint Integrated to Standalone

I'm using RS.exe to migrate from a sharepoint-integrated SSRS server to a standalone SSRS server. When I run the command I think SHOULD work, I get an error related to a missing SiteURL parameter. I want to copy all contents from the source SSRS box to the destination, so my understanding is that the defaults should be acceptable. Documentation for this migration path seems thin. I'd appreciate help in figuring out how to get this done.
Below are the command and error text:
c:\IT>rs.exe -i ssrs_migration.rss -e Mgmt2010 -s http://SPssrs/ReportServer -v ts="http://reporting/ReportServer"
Retrieve and report the list of items that will be migrated. You can cancel the script after step 1 if you do not want to start the actual migration.
Retrieving schedules:
Unhandled exception:
The value for parameter 'SiteUrl' is not specified. It is either missing from the function call, or it is set to null.
Try
rs.exe -i ssrs_migration.rss -e Mgmt2010 -s http://SPssrs/_vti_bin/ReportServer -v ts http://reporting/reportserver

Resources