Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F27645339
Flask/PuppetDB PoC
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
faidon
Dec 19 2018, 6:24 PM
2018-12-19 18:24:27 (UTC+0)
Size
520 B
Referenced Files
None
Subscribers
None
Flask/PuppetDB PoC
View Options
#!/usr/bin/env python3
from
flask
import
Flask
,
abort
,
jsonify
import
pypuppetdb
import
pypuppetdb.QueryBuilder
as
pqb
app
=
Flask
(
__name__
)
# facts that are non-sensitive and safe to process
WHITELIST
=
[
"serial_number"
,
]
@app
.
route
(
'/v1/fact/<fact_name>'
)
def
fact
(
fact_name
):
if
fact_name
not
in
WHITELIST
:
abort
(
403
)
db
=
pypuppetdb
.
connect
()
fact_list
=
db
.
facts
(
query
=
pqb
.
EqualsOperator
(
"name"
,
fact_name
))
result
=
{
f
.
node
:
f
.
value
for
f
in
fact_list
}
return
jsonify
(
result
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6860834
Default Alt Text
Flask/PuppetDB PoC (520 B)
Attached To
Mode
P7931 Flask/PuppetDB PoC
Attached
Detach File
Event Timeline
Log In to Comment