Skip to content

Commit 8861b74

Browse files
authored
Merge pull request #127 from quirky4/server_tags_doc
[ePortal] add documentation for server tags
2 parents 79865d3 + 9c6a1eb commit 8861b74

File tree

4 files changed

+109
-30
lines changed

4 files changed

+109
-30
lines changed
31.2 KB
Loading
28.7 KB
Loading

docs/eportal-api/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,35 @@ Example:
563563
force_basic_auth: yes
564564
```
565565

566+
Example of server tagging:
567+
568+
```json
569+
- hosts: kernelcare
570+
vars:
571+
eportal_srv: http://192.168.246.110
572+
eportal_tags: 'staging;location:Boston'
573+
tasks:
574+
- name: get systemid content
575+
slurp:
576+
src: /etc/sysconfig/kcare/systemid
577+
register: systemid_file
578+
579+
- name: set server_id
580+
set_fact:
581+
eportal_server_id: "{{ systemid_file.content | b64decode | trim | regex_replace('^server_id=(\\w+)$', '\\1') }}"
582+
583+
- name: set server tags using ePortal API
584+
uri:
585+
url: '{{ eportal_srv }}/admin/api/set_tags'
586+
method: POST
587+
headers:
588+
X-Api-Key: '{{ lookup("env", "EPORTAL_API_TOKEN") }}'
589+
body_format: form-urlencoded
590+
body:
591+
server_id: '{{eportal_server_id }}'
592+
tags: '{{ eportal_tags }}'
593+
```
594+
566595
Ad hoc run with:
567596

568597
```
@@ -613,6 +642,28 @@ http_request "kernelcare-unregister-api" do
613642
end
614643
```
615644

645+
Example of server tagging (kernelcare-tag-server.rb):
646+
647+
```json
648+
eportal_url = "http://192.168.246.110"
649+
eportal_api_key = "Lgk5-qWeBypejSEc6nYmalGbv11Kh_OyWi2_vigrTro"
650+
tags = "staging;location:Boston"
651+
652+
ruby_block 'get-server-id' do
653+
block do
654+
node.run_state['server_id'] = File::read('/etc/sysconfig/kcare/systemid').gsub(/server_id=(\w+)\s*/, '\1')
655+
end
656+
action :run
657+
end
658+
659+
http_request 'kernelcare-set-server-tags' do
660+
url "#{eportal_url}/admin/api/set_tags"
661+
action :post
662+
message lazy {{'server_id' => "#{node.run_state['server_id']}", 'tags' => tags}.to_json}
663+
headers({'X-Api-Key' => eportal_api_key, 'Content-Type' => 'application/json'})
664+
end
665+
```
666+
616667
Ad hoc run with:
617668

618669
```
@@ -671,6 +722,20 @@ fi
671722
curl -kL -u "${EPORTAL_API_PASSWORD}"':'"${EPORTAL_API_PASSWORD}" -X POST "${EPORTAL_URL}"'/admin/api/delete_server?ip='"${IP_TO_UNREGISTER}"
672723
```
673724

725+
Example of server tagging (tag_server.sh)
726+
727+
```
728+
#!/bin/bash
729+
730+
EPORTAL_URL='http://192.168.246.110'
731+
EPORTAL_TAGS='staging;location:Boston'
732+
EPORTAL_API_KEY='Lgk5-qWeBypejSEc6nYmalGbv11Kh_OyWi2_vigrTro'
733+
734+
EPORTAL_SERVER_ID=$( grep -oP 'server_id=\K(.+)' /etc/sysconfig/kcare/systemid )
735+
736+
curl -kL -H "X-Api-Key: ${EPORTAL_API_KEY}" --data-urlencode "server_id=${EPORTAL_SERVER_ID}" --data-urlencode "tags=${EPORTAL_TAGS}" "${EPORTAL_URL}/admin/api/set_tags"
737+
```
738+
674739
### Puppet Plan
675740

676741
If you prefer to have a plan rather than a task, then you can create one from this script with the following steps:

docs/eportal/README.md

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,50 @@ A new table is added to the starting page. This table displays the following:
821821

822822
The number of servers for each key is listed on the _Keys_ page.
823823

824+
## Managing server tags
825+
826+
You can use 'Server tags' page to deal with tags.
827+
828+
![server tags view](/images/tags_view.png)
829+
830+
Tagging is a convenient way to group servers by any criteria. For example OS, deployment environment, location, etc.
831+
You need to create a tag and then it can be assigned to a server from the [Managing Servers](#managing-servers) interface.
832+
833+
![tag assignment](/images/tag_assignment.png)
834+
835+
The tag may have an optional value. For example, this allows you to introduce a new geo location without creating a new tag for it.
836+
837+
### Using agent CLI to manage tags
838+
839+
To add an extra Tag field for the server, run:
840+
841+
```text
842+
# kcarectl --tag command
843+
```
844+
845+
where `command` is a parameter defined by a user. This parameter will be displayed in UI for the server. User could add multiple tags for each server. Each tag should be separated with `;` symbol.
846+
847+
Example:
848+
849+
```text
850+
# kcarectl --tag "env:prod;ubuntu"
851+
```
852+
853+
This server has two tags : `env:prod` and `ubuntu`.
854+
855+
`env:prod` is a parameter that has tag name `env` and the value `prod`.
856+
857+
![tags](/images/addingextratagfield_zoom88.png)
858+
859+
To remove all tags from a particular server, run:
860+
861+
```text
862+
# kcarectl --tag ""
863+
```
864+
865+
Where `""` is a parameter to delete the previously defined tag.
866+
867+
824868
## Feed Management
825869

826870
Feeds are intended to manage patchsets on the server, and they provide a possibility to bind a set of patches to a specific key. Possible use cases:
@@ -946,36 +990,6 @@ The API key is personal, meaning it is tied to a specific user and inherits thei
946990
A user with read-only permissions can only manage their own keys,
947991
while an administrator has access to any user's API keys.
948992

949-
## Adding extra Tag field
950-
951-
To add an extra Tag field for the server, run:
952-
953-
```text
954-
# kcarectl --tag command
955-
```
956-
957-
where `command` is a parameter defined by a user. This parameter will be displayed in UI for the server. User could add multiple tags for each server. Each tag should be separated with `;` symbol.
958-
959-
Example:
960-
961-
```text
962-
# kcarectl --tag "env:prod;ubuntu"
963-
```
964-
965-
This server has two tags : `env:prod` and `ubuntu`.
966-
967-
`env:prod` is a parameter that has tag name `env` and the value `prod`.
968-
969-
![tags](/images/addingextratagfield_zoom88.png)
970-
971-
To remove all tags from a particular server, run:
972-
973-
```text
974-
# kcarectl --tag ""
975-
```
976-
977-
Where `""` is a parameter to delete the previously defined tag.
978-
979993
## How to setup ePortal to use HTTPS
980994

981995
Some assumptions for a server where e-portal is deployed:

0 commit comments

Comments
 (0)