SlideShare a Scribd company logo
CLI tools for Foreman
Martin Bačovský
mbacovsk@redhat.com
Agenda
overview of the tools
live examples for individual options
troubleshooting
new features
Foreman API
general purpose API
versioned - v2
extensible from Foreman plugins
same features as in UI
Foreman API
general purpose API
versioned - v2
extensible from Foreman plugins
same features as in UI
➕ fast
➕ well documented
➕ wide range of tools/libs

Recommended for you

The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press

Like many others, WordPress has been my personal blogging tool for a long time. A powerful tool for easy publishing! That is what everyone wants. Large sites like TechCrunch and TheNextWeb use it exactly for that reason. And more enterprises seem to discover it as good solution to their too-expensive publication tools. But keeping those WordPress instances running requires skills and knowledge. Because of WordPress extendibility and its very active community, you can do this too. This tutorial will teach you how use Ansible, Composer, WP-CLI, WP REST API, and Elasticsearch can push WordPress from a personal blogging tool into an enterprise-worthy level application. Out with FTP based SCM ... in with automated deployment, dependency management, and utterly fast search.

ansibletrellisroots.io
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking

The REST API is an awesome plugin to expose your data from the WordPress core. But … the standard implementation might not fit your specific case. Just like the WordPress core, you'll be able to extend it to your specific needs. I'll show you how to handle authentication, introduce caching strategies, alter custom post types, or even change the default way of communication altogether.

wordpresspluginrest api
Flask patterns
Flask patternsFlask patterns
Flask patterns

The document provides an overview of advanced patterns in Flask including: 1. State management using application and request contexts to bind resources like databases. 2. Resource management using teardown callbacks to commit transactions and release resources. 3. Customizing response creation by passing response objects down a stack or replacing implicit responses. 4. Server-sent events for real-time updates using Redis pub/sub and streaming responses. 5. Separating worker processes for blocking and non-blocking tasks using tools like Gunicorn and Nginx. 6. Signing data with ItsDangerous to generate tokens and validate user activations without a database. 7. Customizing Flask like adding cache bust

Foreman API
general purpose API
versioned - v2
extensible from Foreman plugins
same features as in UI
➕ fast
➕ well documented
➕ wide range of tools/libs
➖ usability from shell (curl options, parsing JSON output)
➖ general complexity (routes, inconsistencies across plugins)
Documentation
documented with Apipie
https://<your foreman instance>/apidoc/
structured docs in JSON
localized
https://theforeman.org/api/1.23/index.html
Example
In [203]:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 354 0 354 0 0 1616 0 --:--:-- --:--:-- --:--:-- 1616
{
"total": 2,
"subtotal": 2,
"page": 1,
"per_page": 20,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": [
{
"created_at": "2018-10-08 17:16:11 UTC",
"updated_at": "2018-10-08 17:16:11 UTC",
"name": "x86_64",
"id": 1
}
! curl -k -u admin:changeme -X GET 
-H "Accept:application/json" 
https://centos7-luna-devel.pichi.example.com/api/v2/architectures 
| python -m json.tool
Apipie-bindings
ruby wrapper around Foreman API
simple static library
the API description is loaded from the server
API introspection

Recommended for you

WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking

The REST API is an awesome plugin to expose your data from the WordPress core. But … the standard implementation might not fit your specific case. Just like the WordPress core, you'll be able to extend it to your specific needs. I'll show you how to handle authentication, introduce caching strategies, alter custom post types, or even change the default way of communication altogether.

rest apipluginwordpress
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...

The API Platform framework is a set of tools to help you building API-first projects. The API project Platform is built on top of the Symfony framework, it means you can reuse all your Drupal 8 and Symfony skills and benefit of the incredible amount of Symfony documentation and community bundles. During this session, you will learn how to use the API Platform project to create a modern web application using Symfony, Doctrine, ReactJS, Redux, Redux-Saga, Ant Design and DVA.

symfonyapireact
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo

ruby on rails training session #2: 1) how to add login/logout/signup functions; 2) a functional/unit test; 3) simple ajax to post a weibo.

Apipie-bindings
ruby wrapper around Foreman API
simple static library
the API description is loaded from the server
API introspection
➕ easy to use from Ruby
➕ well tested
➕ it finds the best route based on params
➕ works with any Apipie documented API
➕ logging
Introspection demo
In [204]:
Overwriting foreman_api.rb
%%writefile foreman_api.rb
require 'apipie-bindings'
require 'awesome_print'
def api
ApipieBindings::API.new(
{
:uri => 'https://centos7-luna-devel.pichi.example.com/',
:api_version => 2,
:username => 'admin',
:password => 'changeme'
},
:verify_ssl => false
)
end
In [205]:
#<ApipieBindings::API:0x000000000261d5d0 @uri="https://centos7-luna-devel.pichi.example.com/", @api_version=2, @langu
age=nil, @apidoc_cache_dir="/home/mbacovsk/.cache/apipie_bindings/https___centos7-luna-devel.pichi.example.com_/v2",
@apidoc_cache_name="13c937025f2570a497cca8a51a31a5cc33d0a7a5", @apidoc_authenticated=true, @follow_redirects=:defaul
t, @dry_run=false, @aggressive_cache_checking=false, @fake_responses={}, @logger=#<Logger:0x0000000002eabdc8 @level=
3, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000002eabd50 @datetime_format=nil>, @formatter=nil, @l
ogdev=#<Logger::LogDevice:0x0000000002eabd00 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=ni
l, @dev=#<IO:<STDERR>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0000000002eabc88>>>, @authenticato
r=#<ApipieBindings::Authenticators::BasicAuth:0x0000000002eaace8 @user="admin", @password="changeme">, @resource_conf
ig={:timeout=>nil, :headers=>{:content_type=>"application/json", :accept=>"application/json;version=2"}, :verify_ssl=
>false}, @config={:uri=>"https://centos7-luna-devel.pichi.example.com/", :api_version=>2, :username=>"admin", :passwo
rd=>"changeme"}>
%%ruby
require './foreman_api.rb'
ap api
API has resources
In [206]:
[
[0] <Resource :hosts>,
[1] <Resource :interfaces>,
[2] <Resource :host_subscriptions>,
[3] <Resource :fact_values>,
[4] <Resource :hostgroups>,
[5] <Resource :smart_proxies>,
[6] <Resource :architectures>,
[7] <Resource :audits>,
[8] <Resource :auth_source_externals>,
[9] <Resource :auth_source_internals>
]
%%ruby
require './foreman_api.rb'
ap api.resources[0,10]

Recommended for you

Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2

This document provides an overview of REST (REpresentational State Transfer) and developing REST APIs in Symfony2. It discusses the history and architectural constraints of REST, including being client-server, stateless, cacheable, layered, and having a uniform interface. It also covers REST maturity levels, content negotiation, HTTP methods and status codes, and the HATEOAS principle of providing hypermedia controls. The document concludes by stating it will continue discussing developing REST APIs in Symfony2 in future parts.

symfonysymfony2api
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid

This document discusses using Backbone, Backgrid, and Symfony to build a datagrid application. It covers: 1) Setting up requirements including Symfony, Backbone dependencies, and FOSRestBundle. 2) Building Backbone models, collections, and associations to retrieve and represent ticket data. 3) Implementing a Backgrid grid with columns to display the ticket data. 4) Examples of extending Backgrid with features like select editors, toggle cells, and computed fields. 5) Testing the Backbone collections and API endpoints with sample test code.

php javascript symfony2 backgrid.js backbone.js si
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101

Slides from a presentation given at Laravel Chicago on November 18, 2014. Goes over the basics of building a REST API using the Laravel framework as well as some handy tips and tools.

Resources have actions
In [207]:
[
[0] <Action architectures:index>,
[1] <Action architectures:show>,
[2] <Action architectures:create>,
[3] <Action architectures:update>,
[4] <Action architectures:destroy>
]
%%ruby
require './foreman_api.rb'
ap api.resource(:architectures).actions
Actions can be called
In [208]:
{
"total" => 2,
"subtotal" => 2,
"page" => 1,
"per_page" => 20,
"search" => nil,
"sort" => {
"by" => nil,
"order" => nil
},
"results" => [
[0] {
"created_at" => "2018-10-08 17:16:11 UTC",
"updated_at" => "2018-10-08 17:16:11 UTC",
"name" => "x86_64",
"id" => 1
},
[1] {
"created_at" => "2018-10-08 17:16:11 UTC",
"updated_at" => "2019-11-04 11:40:41 UTC",
"name" => "i486",
"id" => 2
}
]
}
%%ruby
require './foreman_api.rb'
ap api.resource(:architectures).action(:index).call
The following notations are equivalent
api.resource(:architectures).action(:index).call
api.resource(:architectures).call(:index)
api.call(:architectures, :index)
Actions also have params
In [209]:
[
[0] <Param location_id (Numeric)>,
[1] <Param organization_id (Numeric)>,
[2] <Param *id (String)>,
[3] <Param *architecture (Hash)>
]
%%ruby
require './foreman_api.rb'
ap api.resource(:architectures).action(:update).params

Recommended for you

Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites

HA websites are where the rubber meets the road - at 200km/h. Traditional separation of dev and ops just doesn't cut it. Everything is related to everything. Code relies on performant and resilient infrastructure, but highly performant infrastructure will only get a poorly written application so far. Worse still, root cause analysis in HA sites will more often than not identify problems that don't clearly belong to either devs or ops. The two options are collaborate or die. This talk will introduce 3 core principles for improving collaboration between operations and development teams: consistency, repeatability, and visibility. These principles will be investigated with real world case studies and associated technologies audience members can start using now. In particular, there will be a focus on: - fast provisioning of test environments with configuration management - reliable and repeatable automated deployments - application and infrastructure visibility with statistics collection, logging, and visualisation

puppetlca2011technology
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5

This document discusses building REST APIs with Laravel 5. It covers topics like using REST instead of SOAP, authentication with basic authentication and middleware, response formats, controller hierarchy, repositories, data transformers, error handling, and an internal dispatcher for making internal API requests. The goal is to provide best practices and patterns for building robust and well-structured REST APIs with Laravel.

restelena kolevskaapis
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2

This document discusses best practices for developing a REST API in Symfony2. It recommends using bundles like FOSRestBundle, JMSSerializerBundle, and NelmioApiDocBundle. Services should follow the thin controller, fat service pattern. Entities define interfaces and handlers implement business logic. Controllers call handlers and annotations document API endpoints. The document provides examples of entity, interface, controller, and handler code that follow these patterns for CRUD operations on pages.

phprest apisymfony2
Actions also have params
In [209]:
Params can be nested
In [210]:
[
[0] <Param location_id (Numeric)>,
[1] <Param organization_id (Numeric)>,
[2] <Param *id (String)>,
[3] <Param *architecture (Hash)>
]
[
[0] <Param name (String)>,
[1] <Param operatingsystem_ids (Array)>
]
%%ruby
require './foreman_api.rb'
ap api.resource(:architectures).action(:update).params
%%ruby
require './foreman_api.rb'
ap api.resource(:architectures).action(:update).params[3].params
In [212]:
{
"created_at" => "2018-10-08 17:16:11 UTC",
"updated_at" => "2019-11-07 13:38:19 UTC",
"name" => "i586",
"id" => 2,
"operatingsystems" => [
[0] {
"id" => 3,
"name" => "TestOS1",
"title" => "TestOS 1"
},
[1] {
"id" => 2,
"name" => "Windows7EM2019-01",
"title" => "Windows 7 EN (2019-01)"
}
],
"images" => []
}
%%ruby
require './foreman_api.rb'
params = {
:id => 2,
:architecture => {
:name => 'i586'
}}
ap api.call(:architectures, :update, params)
Alternatives for Python
Apypie ( )
Nailgun ( )
https://github.com/Apipie/apypie/tree/master/apypie
https://nailgun.readthedocs.io/en/latest/#
Hammer CLI
command-line client for Foreman
same functionality as UI

Recommended for you

Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18

This document discusses Flask, a Python-based web application framework. It provides an overview of Flask fundamentals like backend development, virtual environments, routes, templates, and error handling. It also covers additional Flask features like extensions, MongoDB integration, and building REST APIs. The document uses code samples and file structure examples to demonstrate how to structure and deploy a Flask application on Heroku.

flask; python; backend; web server; semcomp
Flask – Python
Flask – PythonFlask – Python
Flask – Python

This document provides an overview of Flask, a microframework for Python. It discusses that Flask is easy to code and configure, extensible via extensions, and uses Jinja2 templating and SQLAlchemy ORM. It then provides a step-by-step guide to setting up a Flask application, including creating a virtualenv, basic routing, models, forms, templates, and views. Configuration and running the application are also covered at a high level.

flaskwsgisqlalchemy
Reverse proxies & Inconsistency
Reverse proxies & InconsistencyReverse proxies & Inconsistency
Reverse proxies & Inconsistency

https://2018.zeronights.ru/en/reports/reverse-proxies-inconsistency/ Modern websites are growing more complex with different reverse proxies and balancers covering them. They are used for various purposes: request routing, caching, putting additional headers, restricting access. In other words, reverse proxies must both parse incoming requests and modify them in a particular way. However, path parsing may turn out to be quite a challenge due to mismatches in the parsing of different web servers. Moreover, request converting may imply a wide range of different consequences from a cybersecurity point of view. I have analyzed different reverse proxies with different configurations, the ways they parse requests, apply rules, and perform caching. In this talk, I will both speak about general processes and the intricacies of proxy operation and demonstrate the examples of bypassing restrictions, expanding access to a web application, and new attacks through the web cache deception and cache poisoning.

reverse proxynginxzeronights
Hammer CLI
command-line client for Foreman
same functionality as UI
➕ can combine multiple API calls in a single command
➕ extensible with plugins
➕ processing of input and output
➕ has help
➕ con gurable (auth methods, different servers, ...)
Hammer CLI
command-line client for Foreman
same functionality as UI
➕ can combine multiple API calls in a single command
➕ extensible with plugins
➕ processing of input and output
➕ has help
➕ con gurable (auth methods, different servers, ...)
➖ slow to load
Structure of commands
hammer [global opts] <resource>* <command> [command opts]
global opts (-d, --username, --output, ...)
hammer --help
commands (list, info, create, update, delete, ...)
hammer <resource> --help
command opts (--id, ...)
hammer <resource> <command> --help
In [213]:
Usage:
hammer architecture [OPTIONS] SUBCOMMAND [ARG] ...
Parameters:
SUBCOMMAND Subcommand
[ARG] ... Subcommand arguments
Subcommands:
add-operatingsystem Associate an operating system
create Create an architecture
delete Delete an architecture
info Show an architecture
list List all architectures
remove-operatingsystem Disassociate an operating system
update Update an architecture
Options:
-h, --help Print help
! hammer architecture --help

Recommended for you

Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)

This document is a presentation about PowerShell scripting. It includes an agenda that covers topics like what PowerShell is, installation, basics, commands, variables, loops, applications, and the future of PowerShell. It also provides demonstrations of PowerShell concepts like aliases, the pipeline, drivers/registry, WMI applications, operators, loops/flow control, variables, arrays, forms, and file extensions. The presentation aims to introduce attendees to PowerShell and its capabilities.

Weird proxies/2 and a bit of magic
 Weird proxies/2 and a bit of magic  Weird proxies/2 and a bit of magic
Weird proxies/2 and a bit of magic

https://zeronights.ru/en/reports-en/weird-proxies-2-and-a-bit-of-magic/ Reverse proxies and their variations are used everywhere in modern web applications for routing, caching, and access differentiation. This talk is dedicated to new research results about different reverse proxies and new possibilities brought by HTTP/2. It is a collection of tricks for exploiting various misconfigurations. Results - https://github.com/GrrrDog/weird_proxies

reverse proxyhacking
Development Workflows on AWS
Development Workflows on AWSDevelopment Workflows on AWS
Development Workflows on AWS

A walk-through of powering your end-to-end software development lifecycle using CodeCommit, CodePipeline, and CodeBuild.

awscloud computingaws-loft-london-2017
Con guration
tree ~/.hammer
├── certs
├── cli_config.yml
├── cli.modules.d
│ ├── foreman_remote_execution.yml
│ ├── foreman.yml
│ └── katello.yml
├── defaults.yml
├── log
│ └── hammer.log
├ sessions
Auth methods
basic auth (username and password)
sessions/ no sessions
auth with user access token
OpenID Connect (Keycloak)
client cert
Example access token usage
$ hammer user access-token create --user admin --name demo
Personal access token [demo] created:
jmzOhwHZy9P2fSmRms3i6A
In [214]:
Id: 12
Name: demo
Active: yes
Expires at:
Created at: 2019/11/06 11:52:45
Last used at:
! hammer --username admin --password jmzOhwHZy9P2fSmRms3i6A 
user access-token info --name demo --user admin
Output tuning
Global options
--output [base, table, csv, yaml, json, silent]
--no-headers
--show-ids
Command options
--fields
--page
--per-page

Recommended for you

MongoDB user group israel May
MongoDB user group israel MayMongoDB user group israel May
MongoDB user group israel May

This document discusses protecting MongoDB with a RESTful API. It covers why an API is needed to complement MongoDB and hide implementation details for security, resource management, and schema/referential integrity. The document then discusses RESTful principles and designing RESTful routes for CRUD operations. It provides examples of performing CRUD operations and aggregations using a Python CLI. It also discusses output formats, schema, querying with PQL, BSON/JSON conversion, and references additional resources.

mongodb
Cognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinarCognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinar

The document discusses cognitive data capture using Elis, an AI platform for automating invoice processing. Elis can automate up to 95% of data entry tasks using AI rather than manual work. It allows importing documents, AI processing to extract data, human review if needed, and exporting the captured data. Elis supports customization through extensions and has user management, queue, workspace and schema configuration options that can be managed through its API or command line interface.

data captureapielis
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony

Learn how symfony can make your life simple, especially if you want to develop web applications in a professional way. Warning! Contains PHP code...

Prede ned eld sets for host list
+------------------------+-----+---------+------+
| Fields | ALL | DEFAULT | THIN |
+------------------------+-----+---------+------+
| Id | x | x | x |
| Name | x | x | x |
| Operating System | x | x | |
| IP | x | x | |
| MAC | x | x | |
| Global Status | x | x | |
| Organization | x | | |
| Location | x | | |
| Content View | x | x | |
| Bugfix | x | | |
....
| Enhancement | x | | |
+------------------------+-----+---------+------+
In [215]:
---
- Id: 4
Name: centos7.pichi.example.com
Ip: 192.168.121.172
Organization:
Name: Default Organization
Id: 1
- Id: 6
Name: drew-whyte.pichi.example.com
Ip: 192.168.121.10
Organization:
Name: Default Organization
Id: 1
! hammer --output yaml host list --fields THIN,organization,ip --per-page 2
Search and order lists
--search - scoped search syntax as in the UI
--order - 'id DESC' (may be inconsistent in plugins)
In [216]:
-----------------------------|---------------
NAME | IP
-----------------------------|---------------
drew-whyte.pichi.example.com | 192.168.121.10
-----------------------------|---------------
! hammer host list --search "ip=192.168.121.10" --fields name,ip

Recommended for you

Crossing the Boundaries of Web Applications with OpenSocial
Crossing the Boundaries of Web Applications with OpenSocialCrossing the Boundaries of Web Applications with OpenSocial
Crossing the Boundaries of Web Applications with OpenSocial

Bastian Hofmann presented on OpenSocial, a specification that allows third-party applications called gadgets to be included in social networking services. OpenSocial defines APIs for accessing a user's social graph and features like profiles, groups, and embedded experiences. It also describes how gadgets can be built with HTML, JavaScript, and other web technologies and rendered securely in different containers using techniques like proxies and iframes.

opensocial
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks

This document provides an overview of different frameworks for adding custom fields or metadata to posts in WordPress, including Advanced Custom Fields (ACF), MetaBox.io, Custom Metaboxes 2 (CMB2), and Fieldmanager. It compares the pros and cons of each framework and how to extend their functionality, helping readers choose the best solution for their needs and coding level.

Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks

There are a number of ways to add custom meta boxes to WordPress admin, from coding against core functions through code API frameworks to GUI interfaces. All of these have a place, but which is the right one for your project, code style and coding level? In this talk I will provide code examples and illustrations of the code techniques for each of the methods. Time permitting, I will also show you how to extend the frameworks. Aimed at all levels of developer because of the range of options covered.

Taxonomies
each API endpoint accepts organization_id and location_id
it sets the scope in which the request is evaluated
it is similar to Org/Loc selector in UI
Troubleshooting
--debug global option
check if error messages comes from hammer or API
check for lost API error messages
check server logs (debug verbosity)
see what UI sends if it works there
In [ ]: ! hammer -d os list
In [219]: %%capture request_id
! hammer -d os list 2>&1 | grep x_request_id 
| sed 's/([^"]*"([a-z0-9]*)-.*)/2/' | tr -d '[:cntrl:]'

Recommended for you

Sahana introduction to the code v2
Sahana   introduction to the code v2Sahana   introduction to the code v2
Sahana introduction to the code v2

- The document discusses Sahana Eden, an open-source emergency management system. It provides an overview of the model-view-controller framework and describes how to set up the software and develop new modules. - Instructions are given for building a sample Vehicle Tracking System module, including defining models, controllers, views and integrating it with the core system. - Techniques for joining resources across multiple tables, internationalization, mapping and more are demonstrated through this example.

Sahana Eden - Introduction to the Code
Sahana Eden - Introduction to the CodeSahana Eden - Introduction to the Code
Sahana Eden - Introduction to the Code

A 1/2 day tutorial on how to code in the Sahana Eden framework. (This course is still under development)

Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...

Teleport allows you to implement industry-best practices for SSH and Kubernetes access, meet compliance requirements, and have complete visibility into access and behavior. But invariably, change happens. Teleport allows users to request elevated privileges in the middle of their command-line sessions and create fully auditable dynamic authorizations . These requests can be approved or denied via ChatOps in Slack, in PagerDuty, or anywhere else via a flexible Authorization Workflow API. -The Slack integration allows users to access role permission requests through Slack messages and approve from within the app. -The PagerDuty integration allows Teleport permission requests to function as PagerDuty incidents. They can be approved or denied through a PagerDuty special action. Link to video: https://youtu.be/onyoT8BCSe0

In [219]:
In [220]:
5e456046
%%capture request_id
! hammer -d os list 2>&1 | grep x_request_id 
| sed 's/([^"]*"([a-z0-9]*)-.*)/2/' | tr -d '[:cntrl:]'
print(request_id)
In [219]:
In [220]:
In [221]:
5e456046
2019-11-07T13:49:55 [I|app|5e456046] Started GET "/api/operatingsystems?page=1&per_page=40" for 192.168.121.1 at 2019
-11-07 13:49:55 +0000
2019-11-07T13:49:55 [I|app|5e456046] Processing by Api::V2::OperatingsystemsController#index as JSON
2019-11-07T13:49:55 [I|app|5e456046] Parameters: {"page"=>"1", "per_page"=>"40", "apiv"=>"v2", "operatingsystem"=>
{}}
2019-11-07T13:49:55 [D|app|5e456046] Authenticated user admin against INTERNAL authentication source
2019-11-07T13:49:55 [I|app|5e456046] Authorized user admin(Admin User)
2019-11-07T13:49:55 [D|tax|5e456046] Current location set to none
2019-11-07T13:49:55 [D|tax|5e456046] Current organization set to none
2019-11-07T13:49:55 [D|tax|5e456046] Current location set to none
2019-11-07T13:49:55 [D|tax|5e456046] Current organization set to none
2019-11-07T13:49:55 [I|app|5e456046] Rendering api/v2/operatingsystems/index.json.rabl within api/v2/layouts/index_
layout
2019-11-07T13:49:55 [I|app|5e456046] Rendered api/v2/operatingsystems/index.json.rabl within api/v2/layouts/index_l
ayout (39.7ms)
2019-11-07T13:49:55 [D|app|5e456046] Body: {
2019-11-07T13:49:55 [I|app|5e456046] Completed 200 OK in 605ms (Views: 42.5ms | ActiveRecord: 337.8ms)
%%capture request_id
! hammer -d os list 2>&1 | grep x_request_id 
| sed 's/([^"]*"([a-z0-9]*)-.*)/2/' | tr -d '[:cntrl:]'
print(request_id)
! ssh vagrant@centos7-luna-devel.pichi.example.com 
"grep {request_id} foreman/log/development.log"
Troubleshooting
ask on community.theforeman.org
report issue in projects.theforeman.org
attach debug output
GraphQL
powerfull query language
fresh addition to Foreman
lots of potential

Recommended for you

Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices

This document discusses best practices for developing RESTful APIs and backend services for mobile applications. It recommends using Java, Maven, Spring, Jersey, and Protocol Buffers. Protocol Buffers provide a compact data interchange format that is faster than JSON and more widely supported than other protocols. The document provides an example of implementing authentication, API throttling, caching, testing, and error handling in a RESTful service using these technologies.

javaciklum
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기

The document discusses performance testing of an API server. It provides details on: 1) Preparing for performance testing by generating test data and configuring tools like Artillery to simulate user traffic. 2) Conducting the performance tests on different server configurations to identify bottlenecks, including testing with different Node.js versions. 3) Analyzing the results of the performance tests by profiling requests and examining response times to further optimize the server performance.

node.jsapiperformance
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab

This document provides an overview of Python fundamentals including installing Python, hidden documentation tools, data types, strings, lists, tuples, dictionaries, control flow statements, functions, classes, the datetime library, importing modules, and web2py fundamentals such as the request and response objects, templates, controllers, models, and more. Key concepts covered include Python types like strings, lists, tuples and dictionaries, control structures like if/else and for loops, functions, classes and objects, and the basics of using the web2py framework to build web applications.

GraphQL
powerfull query language
fresh addition to Foreman
lots of potential
➕ comes with handy console in UI
➕ introspection
➕ exibility in queries
GraphQL
powerfull query language
fresh addition to Foreman
lots of potential
➕ comes with handy console in UI
➕ introspection
➕ exibility in queries
➖ no mutations yet
➖ not much feedback on performance
GraphiQL - interractive UI console
> Toolbox > GraphiQLhttps://centos7-luna-devel.pichi.example.com
In [222]:
Overwriting graphql_params.json
%%writefile graphql_params.json
{
"query": "query {
users(first:2) {
totalCount
nodes {
login
mail
}
}
}"
}

Recommended for you

Introduction to python scrapping
Introduction to python scrappingIntroduction to python scrapping
Introduction to python scrapping

This document provides an overview and introduction to web scraping using Python. It discusses what scraping is, how HTTP requests work, important tools for scraping like Beautiful Soup and regular expressions, and techniques like using different user agents. It provides code examples for scraping price data from a website, extracting Facebook permissions, and using Google Translate and the Facebook API to post a translated text to Facebook. It also briefly introduces the Shodan search engine for finding exposed devices on the internet.

BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys LimitedBMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited

New and updated BMC DIscovery Cheat Sheet, quick reference guide and tips for ADDM administrators and sysadmins.

bmcdiscoveryaddm
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices

The document discusses key aspects of building scalable microservices including containerization, orchestration, monitoring, and performance optimization. It provides code examples for containerizing a Node.js application, deploying it with Kubernetes using a Helm chart, and implementing continuous delivery with Jenkins pipelines and DevOps toolchains. The document also covers understanding microservices performance by analyzing architecture diagrams showing public/private networks, services, and databases.

node.jsmicroservicesdevelopment
In [223]:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 335 0 126 100 209 118 197 0:00:01 0:00:01 --:--:-- 316
{
"data": {
"users": {
"totalCount": 6,
"nodes": [
{
"login": "techuser",
"mail": ""
},
{
"login": "admin",
"mail": "root@pichi.example.com"
}
]
}
}
}
! curl -k -u admin:changeme -X POST -H "Content-Type:application/json" 
-H "Accept:application/json" --data @graphql_params.json 
https://centos7-luna-devel.pichi.example.com/api/graphql | python -m json.tool
Report templates
ERB templates
direct access to the data model
macros for easies report formating
see the Foreman Demo #68 for details on usage
prede ned reports are easy to clone and extend
Report templates
ERB templates
direct access to the data model
macros for easies report formating
see the Foreman Demo #68 for details on usage
prede ned reports are easy to clone and extend
➕ complex reports possible
➕ output format according to your needs
➕ instant and scheduled execution
Report templates
ERB templates
direct access to the data model
macros for easies report formating
see the Foreman Demo #68 for details on usage
prede ned reports are easy to clone and extend
➕ complex reports possible
➕ output format according to your needs
➕ instant and scheduled execution
➖ runs in protected environemnt
➖ have to create the template rst

Recommended for you

Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema

This document discusses how to instrument plugins for the MySQL Performance Schema to provide visibility into plugin operations and avoid "black holes" in performance data. It covers the main interfaces for instrumenting threads, file/memory/network operations. An example audit plugin is provided that instruments mutexes, files, stages. The Performance Schema output shows the staged, waited events for a query.

mysql monitoringmysqlmonitoring
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator

The document provides tips for customizing and extending the symfony admin generator. It discusses using PHP configuration instead of YAML, adding relations between models, translating the admin interface, tidying filters, and displaying timestamp fields as plain text. The key recommendations are to understand requirements before using the generator, customize it to suit workflows, and avoid it becoming a messy catch-all solution.

phpadmin generatorsymfony
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation

Airflow is a workflow management system for authoring, scheduling and monitoring workflows or directed acyclic graphs (DAGs) of tasks. It has features like DAGs to define tasks and their relationships, operators to describe tasks, sensors to monitor external systems, hooks to connect to external APIs and databases, and a user interface for visualizing pipelines and monitoring runs. Airflow uses a variety of executors like SequentialExecutor, CeleryExecutor and MesosExecutor to run tasks on schedulers like Celery or Kubernetes. It provides security features like authentication, authorization and impersonation to manage access.

airflowilias okachaapache airflow
Available report templates
In [224]:
----|------------------
ID | NAME
----|------------------
143 | Applicable errata
157 | Applied Errata
105 | Host statuses
142 | Registered hosts
144 | Subscriptions
----|------------------
! hammer report-template list
Report generation
In [225]:
---
- Host: centos7.pichi.example.com
Operating System: Centos 7.5
Environment: Development
Erratum: RHEA-2012:0055
Type: security
Published: '2012-01-27'
Applicable since: 2018-10-08 18:03:07 UTC
Severity: ''
Packages:
- penguin
- shark
- walrus
CVEs: []
Reboot suggested: false
! hammer report-template generate --name "Applicable errata" 
--report-format yaml
Foreman ansible modules
perfect for Foreman setup with Ansible
Foreman clones for testing
fresh addition
multiple alternatives
https://github.com/theforeman/foreman-ansible-modules
Foreman maintain
tool to make maintenance tasks easier
health checks
backup / restore
services
upgrades
...
current support for Foreman is not complete
upgrades of Foreman and Debian support is WIP
plans to wrap various maintenance scripts

Recommended for you

Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)

This document outlines steps to build a Twitter explorer application using Python and Flask. It begins with setting up the virtual environment and cloning the GitHub repository. It then walks through steps to add basic functionality like configuration, templates, a database with SQLAlchemy ORM, user authentication with Flask plugins, and finally integrating the Twitter API. Each step includes changes to files, dependencies in requirements.txt, and commands to test and view progress. The goal is to create a full-stack web application to explore tweets from the Twitter API.

workshopflask
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...

Presentation to Wing wing community. Porting "Blue Zone" application featured in the "Hexagonal Architecture Explained" book.

cloudinfrastructure from codewinglang
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial Company

NBFC Software: Optimize Your Non-Banking Financial Company Enhance Your Financial Services with Comprehensive NBFC Software NBFC software provides a complete solution for non-banking financial companies, streamlining banking and accounting functions to reduce operational costs. Our software is designed to meet the diverse needs of NBFCs, including investment banks, insurance companies, and hedge funds. Key Features of NBFC Software: Centralized Database: Facilitates inter-branch collaboration and smooth operations with a unified platform. Automation: Simplifies loan lifecycle management and account maintenance, ensuring efficient delivery of financial services. Customization: Highly customizable to fit specific business needs, offering flexibility in managing various loan types such as home loans, mortgage loans, personal loans, and more. Security: Ensures safe and secure handling of financial transactions and sensitive data. User-Friendly Interface: Designed to be intuitive and easy to use, reducing the learning curve for employees. Cost-Effective: Reduces the need for additional manpower by automating tasks, making it a budget-friendly solution. Benefits of NBFC Software: Go Paperless: Transition to a fully digital operation, eliminating offline work. Transparency: Enables managers and executives to monitor various points of the banking process easily. Defaulter Tracking: Helps track loan defaulters, maintaining a healthy loan management system. Increased Accessibility: Cutting-edge technology increases the accessibility and usability of NBFC operations. Request a Demo Now!

nbfc softwarenbfc software solutionsnbfc software company
Service status with foreman-maintain
In [226]:
Running Status Services
================================================================================
Get status of applicable services:
Displaying the following service(s):
rh-mongodb34-mongod, postgresql, qdrouterd, qpidd, squid, pulp_celerybeat, pulp_resource_manager, pulp_streamer, pulp
_workers, tomcat, httpd, puppetserver, foreman-proxy
 displaying rh-mongodb34-mongod [OK]
 displaying postgresql [OK]
 displaying qdrouterd [OK]
 displaying qpidd [OK]
 displaying squid [OK]
 displaying pulp_celerybeat [OK]
 displaying pulp_resource_manager [OK]
 displaying pulp_streamer [OK]
 displaying pulp_workers [OK]
 displaying tomcat [OK]
 displaying httpd [OK]
 displaying puppetserver [OK]
| displaying foreman-proxy [OK]
| All services are running [OK]
--------------------------------------------------------------------------------
! ssh 'root@centos7-luna-devel.pichi.example.com' 
"foreman-maintain service status -b"
Questions?

More Related Content

What's hot

Apigility reloaded
Apigility reloadedApigility reloaded
Apigility reloaded
Ralf Eggert
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
Robert Gogolok
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
shaokun
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
Jeroen van Dijk
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
Jeroen van Dijk
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
it-people
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
Jeroen van Dijk
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Jesus Manuel Olivas
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
shaokun
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
Sumy PHP User Grpoup
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
eugenio pombi
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
Lindsay Holmwood
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
Sumy PHP User Grpoup
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
Lar21
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
Reverse proxies & Inconsistency
Reverse proxies & InconsistencyReverse proxies & Inconsistency
Reverse proxies & Inconsistency
GreenD0g
 
Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)
ÇözümPARK
 
Weird proxies/2 and a bit of magic
 Weird proxies/2 and a bit of magic  Weird proxies/2 and a bit of magic
Weird proxies/2 and a bit of magic
GreenD0g
 

What's hot (20)

Apigility reloaded
Apigility reloadedApigility reloaded
Apigility reloaded
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
WordPress REST API hacking
WordPress REST API hackingWordPress REST API hacking
WordPress REST API hacking
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Reverse proxies & Inconsistency
Reverse proxies & InconsistencyReverse proxies & Inconsistency
Reverse proxies & Inconsistency
 
Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)
 
Weird proxies/2 and a bit of magic
 Weird proxies/2 and a bit of magic  Weird proxies/2 and a bit of magic
Weird proxies/2 and a bit of magic
 

Similar to OSCamp #4 on Foreman | CLI tools with Foreman by Martin Bačovský

Development Workflows on AWS
Development Workflows on AWSDevelopment Workflows on AWS
Development Workflows on AWS
Amazon Web Services
 
MongoDB user group israel May
MongoDB user group israel MayMongoDB user group israel May
MongoDB user group israel May
Alon Horev
 
Cognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinarCognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinar
Petr Baudis
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
Francois Zaninotto
 
Crossing the Boundaries of Web Applications with OpenSocial
Crossing the Boundaries of Web Applications with OpenSocialCrossing the Boundaries of Web Applications with OpenSocial
Crossing the Boundaries of Web Applications with OpenSocial
Bastian Hofmann
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
wcto2017
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
Kiera Howe
 
Sahana introduction to the code v2
Sahana   introduction to the code v2Sahana   introduction to the code v2
Sahana introduction to the code v2
AidIQ
 
Sahana Eden - Introduction to the Code
Sahana Eden - Introduction to the CodeSahana Eden - Introduction to the Code
Sahana Eden - Introduction to the Code
AidIQ
 
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Teleport
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
ciklum_ods
 
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기
JeongHun Byeon
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
Colin Su
 
Introduction to python scrapping
Introduction to python scrappingIntroduction to python scrapping
Introduction to python scrapping
n|u - The Open Security Community
 
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys LimitedBMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
Wes Moskal-Fitzpatrick
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
Chris Bailey
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema
Mark Leith
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator
John Cleveley
 
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation
Ilias Okacha
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
Yuriy Senko
 

Similar to OSCamp #4 on Foreman | CLI tools with Foreman by Martin Bačovský (20)

Development Workflows on AWS
Development Workflows on AWSDevelopment Workflows on AWS
Development Workflows on AWS
 
MongoDB user group israel May
MongoDB user group israel MayMongoDB user group israel May
MongoDB user group israel May
 
Cognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinarCognitive data capture with Elis - Rossum's technical webinar
Cognitive data capture with Elis - Rossum's technical webinar
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Crossing the Boundaries of Web Applications with OpenSocial
Crossing the Boundaries of Web Applications with OpenSocialCrossing the Boundaries of Web Applications with OpenSocial
Crossing the Boundaries of Web Applications with OpenSocial
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 
Sahana introduction to the code v2
Sahana   introduction to the code v2Sahana   introduction to the code v2
Sahana introduction to the code v2
 
Sahana Eden - Introduction to the Code
Sahana Eden - Introduction to the CodeSahana Eden - Introduction to the Code
Sahana Eden - Introduction to the Code
 
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
Webinar - 2020-09-23 - Escape the ticketing turmoil with Teleport PagerDuty &...
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
 
Introduction to python scrapping
Introduction to python scrappingIntroduction to python scrapping
Introduction to python scrapping
 
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys LimitedBMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator
 
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
 

Recently uploaded

Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Softwares
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
Ortus Solutions, Corp
 
dachnug51 - Whats new in domino 14 .pdf
dachnug51 - Whats new in domino 14  .pdfdachnug51 - Whats new in domino 14  .pdf
dachnug51 - Whats new in domino 14 .pdf
DNUG e.V.
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Trackobit
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
SimonedeGijt
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
SSTech System
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
onemonitarsoftware
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Livetecs LLC
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
Severalnines
 
Overview of ERP - Mechlin Technologies.pptx
Overview of ERP - Mechlin Technologies.pptxOverview of ERP - Mechlin Technologies.pptx
Overview of ERP - Mechlin Technologies.pptx
Mitchell Marsh
 
BITCOIN HEIST RANSOMEWARE ATTACK PREDICTION
BITCOIN HEIST RANSOMEWARE ATTACK PREDICTIONBITCOIN HEIST RANSOMEWARE ATTACK PREDICTION
BITCOIN HEIST RANSOMEWARE ATTACK PREDICTION
ssuser2b426d1
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
Ortus Solutions, Corp
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
Roshan Dwivedi
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
TwisterTools
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Sparity1
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
karim wahed
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdfAWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
karim wahed
 

Recently uploaded (20)

Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
NBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial CompanyNBFC Software: Optimize Your Non-Banking Financial Company
NBFC Software: Optimize Your Non-Banking Financial Company
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
 
dachnug51 - Whats new in domino 14 .pdf
dachnug51 - Whats new in domino 14  .pdfdachnug51 - Whats new in domino 14  .pdf
dachnug51 - Whats new in domino 14 .pdf
 
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdfResponsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
Responsibilities of Fleet Managers and How TrackoBit Can Assist.pdf
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptxWired_2.0_Create_AmsterdamJUG_09072024.pptx
Wired_2.0_Create_AmsterdamJUG_09072024.pptx
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
 
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
Discover the Power of ONEMONITAR: The Ultimate Mobile Spy App for Android Dev...
 
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdfIndependence Day Hasn’t Always Been a U.S. Holiday.pdf
Independence Day Hasn’t Always Been a U.S. Holiday.pdf
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
 
Overview of ERP - Mechlin Technologies.pptx
Overview of ERP - Mechlin Technologies.pptxOverview of ERP - Mechlin Technologies.pptx
Overview of ERP - Mechlin Technologies.pptx
 
BITCOIN HEIST RANSOMEWARE ATTACK PREDICTION
BITCOIN HEIST RANSOMEWARE ATTACK PREDICTIONBITCOIN HEIST RANSOMEWARE ATTACK PREDICTION
BITCOIN HEIST RANSOMEWARE ATTACK PREDICTION
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
 
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
FAST Channels: Explosive Growth Forecast 2024-2027 (Buckle Up!)
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) Course Introducti...
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdfAWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
 

OSCamp #4 on Foreman | CLI tools with Foreman by Martin Bačovský

  • 1. CLI tools for Foreman Martin Bačovský mbacovsk@redhat.com
  • 2. Agenda overview of the tools live examples for individual options troubleshooting new features
  • 3. Foreman API general purpose API versioned - v2 extensible from Foreman plugins same features as in UI
  • 4. Foreman API general purpose API versioned - v2 extensible from Foreman plugins same features as in UI ➕ fast ➕ well documented ➕ wide range of tools/libs
  • 5. Foreman API general purpose API versioned - v2 extensible from Foreman plugins same features as in UI ➕ fast ➕ well documented ➕ wide range of tools/libs ➖ usability from shell (curl options, parsing JSON output) ➖ general complexity (routes, inconsistencies across plugins)
  • 6. Documentation documented with Apipie https://<your foreman instance>/apidoc/ structured docs in JSON localized https://theforeman.org/api/1.23/index.html
  • 7. Example In [203]: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 354 0 354 0 0 1616 0 --:--:-- --:--:-- --:--:-- 1616 { "total": 2, "subtotal": 2, "page": 1, "per_page": 20, "search": null, "sort": { "by": null, "order": null }, "results": [ { "created_at": "2018-10-08 17:16:11 UTC", "updated_at": "2018-10-08 17:16:11 UTC", "name": "x86_64", "id": 1 } ! curl -k -u admin:changeme -X GET -H "Accept:application/json" https://centos7-luna-devel.pichi.example.com/api/v2/architectures | python -m json.tool
  • 8. Apipie-bindings ruby wrapper around Foreman API simple static library the API description is loaded from the server API introspection
  • 9. Apipie-bindings ruby wrapper around Foreman API simple static library the API description is loaded from the server API introspection ➕ easy to use from Ruby ➕ well tested ➕ it finds the best route based on params ➕ works with any Apipie documented API ➕ logging
  • 10. Introspection demo In [204]: Overwriting foreman_api.rb %%writefile foreman_api.rb require 'apipie-bindings' require 'awesome_print' def api ApipieBindings::API.new( { :uri => 'https://centos7-luna-devel.pichi.example.com/', :api_version => 2, :username => 'admin', :password => 'changeme' }, :verify_ssl => false ) end
  • 11. In [205]: #<ApipieBindings::API:0x000000000261d5d0 @uri="https://centos7-luna-devel.pichi.example.com/", @api_version=2, @langu age=nil, @apidoc_cache_dir="/home/mbacovsk/.cache/apipie_bindings/https___centos7-luna-devel.pichi.example.com_/v2", @apidoc_cache_name="13c937025f2570a497cca8a51a31a5cc33d0a7a5", @apidoc_authenticated=true, @follow_redirects=:defaul t, @dry_run=false, @aggressive_cache_checking=false, @fake_responses={}, @logger=#<Logger:0x0000000002eabdc8 @level= 3, @progname=nil, @default_formatter=#<Logger::Formatter:0x0000000002eabd50 @datetime_format=nil>, @formatter=nil, @l ogdev=#<Logger::LogDevice:0x0000000002eabd00 @shift_period_suffix=nil, @shift_size=nil, @shift_age=nil, @filename=ni l, @dev=#<IO:<STDERR>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0000000002eabc88>>>, @authenticato r=#<ApipieBindings::Authenticators::BasicAuth:0x0000000002eaace8 @user="admin", @password="changeme">, @resource_conf ig={:timeout=>nil, :headers=>{:content_type=>"application/json", :accept=>"application/json;version=2"}, :verify_ssl= >false}, @config={:uri=>"https://centos7-luna-devel.pichi.example.com/", :api_version=>2, :username=>"admin", :passwo rd=>"changeme"}> %%ruby require './foreman_api.rb' ap api
  • 12. API has resources In [206]: [ [0] <Resource :hosts>, [1] <Resource :interfaces>, [2] <Resource :host_subscriptions>, [3] <Resource :fact_values>, [4] <Resource :hostgroups>, [5] <Resource :smart_proxies>, [6] <Resource :architectures>, [7] <Resource :audits>, [8] <Resource :auth_source_externals>, [9] <Resource :auth_source_internals> ] %%ruby require './foreman_api.rb' ap api.resources[0,10]
  • 13. Resources have actions In [207]: [ [0] <Action architectures:index>, [1] <Action architectures:show>, [2] <Action architectures:create>, [3] <Action architectures:update>, [4] <Action architectures:destroy> ] %%ruby require './foreman_api.rb' ap api.resource(:architectures).actions
  • 14. Actions can be called In [208]: { "total" => 2, "subtotal" => 2, "page" => 1, "per_page" => 20, "search" => nil, "sort" => { "by" => nil, "order" => nil }, "results" => [ [0] { "created_at" => "2018-10-08 17:16:11 UTC", "updated_at" => "2018-10-08 17:16:11 UTC", "name" => "x86_64", "id" => 1 }, [1] { "created_at" => "2018-10-08 17:16:11 UTC", "updated_at" => "2019-11-04 11:40:41 UTC", "name" => "i486", "id" => 2 } ] } %%ruby require './foreman_api.rb' ap api.resource(:architectures).action(:index).call
  • 15. The following notations are equivalent api.resource(:architectures).action(:index).call api.resource(:architectures).call(:index) api.call(:architectures, :index)
  • 16. Actions also have params In [209]: [ [0] <Param location_id (Numeric)>, [1] <Param organization_id (Numeric)>, [2] <Param *id (String)>, [3] <Param *architecture (Hash)> ] %%ruby require './foreman_api.rb' ap api.resource(:architectures).action(:update).params
  • 17. Actions also have params In [209]: Params can be nested In [210]: [ [0] <Param location_id (Numeric)>, [1] <Param organization_id (Numeric)>, [2] <Param *id (String)>, [3] <Param *architecture (Hash)> ] [ [0] <Param name (String)>, [1] <Param operatingsystem_ids (Array)> ] %%ruby require './foreman_api.rb' ap api.resource(:architectures).action(:update).params %%ruby require './foreman_api.rb' ap api.resource(:architectures).action(:update).params[3].params
  • 18. In [212]: { "created_at" => "2018-10-08 17:16:11 UTC", "updated_at" => "2019-11-07 13:38:19 UTC", "name" => "i586", "id" => 2, "operatingsystems" => [ [0] { "id" => 3, "name" => "TestOS1", "title" => "TestOS 1" }, [1] { "id" => 2, "name" => "Windows7EM2019-01", "title" => "Windows 7 EN (2019-01)" } ], "images" => [] } %%ruby require './foreman_api.rb' params = { :id => 2, :architecture => { :name => 'i586' }} ap api.call(:architectures, :update, params)
  • 19. Alternatives for Python Apypie ( ) Nailgun ( ) https://github.com/Apipie/apypie/tree/master/apypie https://nailgun.readthedocs.io/en/latest/#
  • 20. Hammer CLI command-line client for Foreman same functionality as UI
  • 21. Hammer CLI command-line client for Foreman same functionality as UI ➕ can combine multiple API calls in a single command ➕ extensible with plugins ➕ processing of input and output ➕ has help ➕ con gurable (auth methods, different servers, ...)
  • 22. Hammer CLI command-line client for Foreman same functionality as UI ➕ can combine multiple API calls in a single command ➕ extensible with plugins ➕ processing of input and output ➕ has help ➕ con gurable (auth methods, different servers, ...) ➖ slow to load
  • 23. Structure of commands hammer [global opts] <resource>* <command> [command opts] global opts (-d, --username, --output, ...) hammer --help commands (list, info, create, update, delete, ...) hammer <resource> --help command opts (--id, ...) hammer <resource> <command> --help
  • 24. In [213]: Usage: hammer architecture [OPTIONS] SUBCOMMAND [ARG] ... Parameters: SUBCOMMAND Subcommand [ARG] ... Subcommand arguments Subcommands: add-operatingsystem Associate an operating system create Create an architecture delete Delete an architecture info Show an architecture list List all architectures remove-operatingsystem Disassociate an operating system update Update an architecture Options: -h, --help Print help ! hammer architecture --help
  • 25. Con guration tree ~/.hammer ├── certs ├── cli_config.yml ├── cli.modules.d │ ├── foreman_remote_execution.yml │ ├── foreman.yml │ └── katello.yml ├── defaults.yml ├── log │ └── hammer.log ├ sessions
  • 26. Auth methods basic auth (username and password) sessions/ no sessions auth with user access token OpenID Connect (Keycloak) client cert
  • 27. Example access token usage $ hammer user access-token create --user admin --name demo Personal access token [demo] created: jmzOhwHZy9P2fSmRms3i6A In [214]: Id: 12 Name: demo Active: yes Expires at: Created at: 2019/11/06 11:52:45 Last used at: ! hammer --username admin --password jmzOhwHZy9P2fSmRms3i6A user access-token info --name demo --user admin
  • 28. Output tuning Global options --output [base, table, csv, yaml, json, silent] --no-headers --show-ids Command options --fields --page --per-page
  • 29. Prede ned eld sets for host list +------------------------+-----+---------+------+ | Fields | ALL | DEFAULT | THIN | +------------------------+-----+---------+------+ | Id | x | x | x | | Name | x | x | x | | Operating System | x | x | | | IP | x | x | | | MAC | x | x | | | Global Status | x | x | | | Organization | x | | | | Location | x | | | | Content View | x | x | | | Bugfix | x | | | .... | Enhancement | x | | | +------------------------+-----+---------+------+
  • 30. In [215]: --- - Id: 4 Name: centos7.pichi.example.com Ip: 192.168.121.172 Organization: Name: Default Organization Id: 1 - Id: 6 Name: drew-whyte.pichi.example.com Ip: 192.168.121.10 Organization: Name: Default Organization Id: 1 ! hammer --output yaml host list --fields THIN,organization,ip --per-page 2
  • 31. Search and order lists --search - scoped search syntax as in the UI --order - 'id DESC' (may be inconsistent in plugins)
  • 32. In [216]: -----------------------------|--------------- NAME | IP -----------------------------|--------------- drew-whyte.pichi.example.com | 192.168.121.10 -----------------------------|--------------- ! hammer host list --search "ip=192.168.121.10" --fields name,ip
  • 33. Taxonomies each API endpoint accepts organization_id and location_id it sets the scope in which the request is evaluated it is similar to Org/Loc selector in UI
  • 34. Troubleshooting --debug global option check if error messages comes from hammer or API check for lost API error messages check server logs (debug verbosity) see what UI sends if it works there
  • 35. In [ ]: ! hammer -d os list
  • 36. In [219]: %%capture request_id ! hammer -d os list 2>&1 | grep x_request_id | sed 's/([^"]*"([a-z0-9]*)-.*)/2/' | tr -d '[:cntrl:]'
  • 37. In [219]: In [220]: 5e456046 %%capture request_id ! hammer -d os list 2>&1 | grep x_request_id | sed 's/([^"]*"([a-z0-9]*)-.*)/2/' | tr -d '[:cntrl:]' print(request_id)
  • 38. In [219]: In [220]: In [221]: 5e456046 2019-11-07T13:49:55 [I|app|5e456046] Started GET "/api/operatingsystems?page=1&per_page=40" for 192.168.121.1 at 2019 -11-07 13:49:55 +0000 2019-11-07T13:49:55 [I|app|5e456046] Processing by Api::V2::OperatingsystemsController#index as JSON 2019-11-07T13:49:55 [I|app|5e456046] Parameters: {"page"=>"1", "per_page"=>"40", "apiv"=>"v2", "operatingsystem"=> {}} 2019-11-07T13:49:55 [D|app|5e456046] Authenticated user admin against INTERNAL authentication source 2019-11-07T13:49:55 [I|app|5e456046] Authorized user admin(Admin User) 2019-11-07T13:49:55 [D|tax|5e456046] Current location set to none 2019-11-07T13:49:55 [D|tax|5e456046] Current organization set to none 2019-11-07T13:49:55 [D|tax|5e456046] Current location set to none 2019-11-07T13:49:55 [D|tax|5e456046] Current organization set to none 2019-11-07T13:49:55 [I|app|5e456046] Rendering api/v2/operatingsystems/index.json.rabl within api/v2/layouts/index_ layout 2019-11-07T13:49:55 [I|app|5e456046] Rendered api/v2/operatingsystems/index.json.rabl within api/v2/layouts/index_l ayout (39.7ms) 2019-11-07T13:49:55 [D|app|5e456046] Body: { 2019-11-07T13:49:55 [I|app|5e456046] Completed 200 OK in 605ms (Views: 42.5ms | ActiveRecord: 337.8ms) %%capture request_id ! hammer -d os list 2>&1 | grep x_request_id | sed 's/([^"]*"([a-z0-9]*)-.*)/2/' | tr -d '[:cntrl:]' print(request_id) ! ssh vagrant@centos7-luna-devel.pichi.example.com "grep {request_id} foreman/log/development.log"
  • 39. Troubleshooting ask on community.theforeman.org report issue in projects.theforeman.org attach debug output
  • 40. GraphQL powerfull query language fresh addition to Foreman lots of potential
  • 41. GraphQL powerfull query language fresh addition to Foreman lots of potential ➕ comes with handy console in UI ➕ introspection ➕ exibility in queries
  • 42. GraphQL powerfull query language fresh addition to Foreman lots of potential ➕ comes with handy console in UI ➕ introspection ➕ exibility in queries ➖ no mutations yet ➖ not much feedback on performance
  • 43. GraphiQL - interractive UI console > Toolbox > GraphiQLhttps://centos7-luna-devel.pichi.example.com
  • 44. In [222]: Overwriting graphql_params.json %%writefile graphql_params.json { "query": "query { users(first:2) { totalCount nodes { login mail } } }" }
  • 45. In [223]: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 335 0 126 100 209 118 197 0:00:01 0:00:01 --:--:-- 316 { "data": { "users": { "totalCount": 6, "nodes": [ { "login": "techuser", "mail": "" }, { "login": "admin", "mail": "root@pichi.example.com" } ] } } } ! curl -k -u admin:changeme -X POST -H "Content-Type:application/json" -H "Accept:application/json" --data @graphql_params.json https://centos7-luna-devel.pichi.example.com/api/graphql | python -m json.tool
  • 46. Report templates ERB templates direct access to the data model macros for easies report formating see the Foreman Demo #68 for details on usage prede ned reports are easy to clone and extend
  • 47. Report templates ERB templates direct access to the data model macros for easies report formating see the Foreman Demo #68 for details on usage prede ned reports are easy to clone and extend ➕ complex reports possible ➕ output format according to your needs ➕ instant and scheduled execution
  • 48. Report templates ERB templates direct access to the data model macros for easies report formating see the Foreman Demo #68 for details on usage prede ned reports are easy to clone and extend ➕ complex reports possible ➕ output format according to your needs ➕ instant and scheduled execution ➖ runs in protected environemnt ➖ have to create the template rst
  • 49. Available report templates In [224]: ----|------------------ ID | NAME ----|------------------ 143 | Applicable errata 157 | Applied Errata 105 | Host statuses 142 | Registered hosts 144 | Subscriptions ----|------------------ ! hammer report-template list
  • 50. Report generation In [225]: --- - Host: centos7.pichi.example.com Operating System: Centos 7.5 Environment: Development Erratum: RHEA-2012:0055 Type: security Published: '2012-01-27' Applicable since: 2018-10-08 18:03:07 UTC Severity: '' Packages: - penguin - shark - walrus CVEs: [] Reboot suggested: false ! hammer report-template generate --name "Applicable errata" --report-format yaml
  • 51. Foreman ansible modules perfect for Foreman setup with Ansible Foreman clones for testing fresh addition multiple alternatives https://github.com/theforeman/foreman-ansible-modules
  • 52. Foreman maintain tool to make maintenance tasks easier health checks backup / restore services upgrades ... current support for Foreman is not complete upgrades of Foreman and Debian support is WIP plans to wrap various maintenance scripts
  • 53. Service status with foreman-maintain In [226]: Running Status Services ================================================================================ Get status of applicable services: Displaying the following service(s): rh-mongodb34-mongod, postgresql, qdrouterd, qpidd, squid, pulp_celerybeat, pulp_resource_manager, pulp_streamer, pulp _workers, tomcat, httpd, puppetserver, foreman-proxy displaying rh-mongodb34-mongod [OK] displaying postgresql [OK] displaying qdrouterd [OK] displaying qpidd [OK] displaying squid [OK] displaying pulp_celerybeat [OK] displaying pulp_resource_manager [OK] displaying pulp_streamer [OK] displaying pulp_workers [OK] displaying tomcat [OK] displaying httpd [OK] displaying puppetserver [OK] | displaying foreman-proxy [OK] | All services are running [OK] -------------------------------------------------------------------------------- ! ssh 'root@centos7-luna-devel.pichi.example.com' "foreman-maintain service status -b"