Skip to content

Commit 289dcd5

Browse files
authored
Merge pull request #2594 from craigcomstock/delete-feeder-from-hubs-table
ENT-8241 Add needed steps to removing FR feeder deletion steps
2 parents 468e20a + 5d8e501 commit 289dcd5

File tree

1 file changed

+103
-43
lines changed

1 file changed

+103
-43
lines changed

enterprise-cfengine-guide/federated-reporting.markdown

Lines changed: 103 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ $ export FEEDER=34.244.118.58
232232
$ export FEEDER_BS=172.31.43.102 # _BS is bootstrap IP
233233
```
234234

235+
In these examples we use the `admin` account because the Admin Role which this user has contains the proper Role Based Access Control privileges to access the needed API endpoints.
236+
235237
### Stop cf-execd on the superhub and feeder
236238

237239
We don't want periodic agent runs to get in our ways so let's disable
@@ -571,55 +573,113 @@ you wish to disable and change the top-level `target_state` property value to `o
571573
### Remove Feeder from Mission Portal Hub Management
572574

573575
At this time it is not possible to remove a connected hub in the Mission Portal Hub
574-
management app. The recommended way to remove a connected hub is with the API.
576+
management app.
575577

576-
First list all feeders to find the id value. Use of ```jq``` is optional for pretty printing the JSON.
578+
* List all feeders to find the id value. Use of ```jq``` is optional for pretty printing the JSON.
577579

578-
```console
579-
$ curl -k -s -X GET -u admin:$PASSWORD https://$SUPERHUB/api/fr/remote-hub | jq '.'
580-
```
580+
(Set approprivate values in your shell for `PASSWORD` and `SUPERHUB`)
581+
```console
582+
$ curl -k -s -X GET -u admin:$PASSWORD https://$SUPERHUB/api/fr/remote-hub | jq '.'
583+
```
581584

582-
```json
583-
{
584-
"id": 1,
585-
"hostkey": "SHA=cd4be31f20f0c7d019a5d3bfe368415f2d34fec8af26ee28c4c123c6a0af49a2",
586-
"api_url": "https://100.90.80.70",
587-
"ui_name": "feeder1",
588-
"role": "feeder",
589-
"target_state": "on",
590-
"transport": {
591-
"mode": "pull_over_rsync",
592-
"ssh_user": "cftransport",
593-
"ssh_host": "172.32.1.20",
594-
"ssh_pubkey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVGoBB3zLKfVTzDNum/JWlmNJrSuDGrhTW1ZGtZEKjxFViFr4j0F8s6gIr5KOMcWtd91XvW6klpCPqKH3lfY767AI/RQa8JgVXgtvUG8rkD+gJ/wzGJm+VoGpxxs9dyBgSOtkaOSIDc574Om8dBR8enRcgxo1cNpvDVLVYKx9IzqhBwqp1gzEtGoIi+CDoGmoj1BT9XTlCRvGXYmSSBrgLARVO2mh5iqhP0XRVCp9Ki6OB9vMcs9rxIgQaPt8tVCt7/FK03IXrWPUsJC4M/kXiaKgHlE96H0CEvYl7GczaIU2NN5AHXZlviL79Zb8kOcUzsMdKv40G9YVa7/kyDOUX root@ip-172-32-1-20",
595-
"ssh_fingerprint": "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBF18li5PyCyVy27+Lv09HDRxhyEnlL+zK++WaLc78W+Gji5i2VSRDg/jVV0xU2ZUmkohULZ66OmI5/sCOOIa3XU=\nssh-ed25519"
596-
},
597-
"statistics": []
598-
}
599-
{
600-
"id": 2,
601-
"hostkey": "SHA=30b6bb15fb94c9b7e386521bbe566934d266db2f6f63cd85f5e6fc406d11110b",
602-
"api_url": "https://100.90.80.60",
603-
"ui_name": "feeder2",
604-
"role": "feeder",
605-
"target_state": "on",
606-
"transport": {
607-
"mode": "pull_over_rsync",
608-
"ssh_user": "cftransport",
609-
"ssh_host": "172.32.1.21",
610-
"ssh_pubkey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDin59ffTXhtQxahrYkqNi3x36XIO08GnOvvVe3s+DmuT3kBn8Lh4P30kOVONSGKcfNZLnWVPrk2qqNWuEi6xg861G1kXqce02c26BW+4L/tnz86/kmTBGc2vb6d1NpEKA/1bg6bMf1da+EInxuMsS+yOWCe+s6DJ00bg6iCnmlLYtzAkMXmXK5QgVG6AImJXqG1Px5DlsRcKto00J8WJswfTpQXbZbuog4J6Ltm/J4DQW1/x7pEJby/r+/lKPJWp19t0gaGXfsxwHEPFK6YC8zmFzkBeqiVpAizhs7G8mZDgAAhMyY8d2eYIp+hDIFpfQA3aHHr0L7emsFeDa/rExt root@ip-172-32-1-21",
611-
"ssh_fingerprint": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7HE4qJfTLP9j02jZnkpTpUMCBiFzmAemgvIPcJjWJVNcawh1hpGSsWjw9EM1kwn7J6fWrjEkY8lTi2pNTnobL9qt+oQvwFqUvs5EZ8gAVIAyDjKE8GLckZRt8VGxLWMtOlBKaAmPBn0eFP6ToPqnPygJiiM05vKtxPui1xuCTrW+rXShtolUJLwwGH2APcDqjKAdZceQK4nybJzk4J1P77sJc+9IlHJCTpfj8AQEbh/Z3cHtNKauaz1mhDn5YT/QWwzKavGlqFSlSDwLXT2go6P6FoSaVYTV45V9l7q6ahEy3zEe7+7psMFVucS512qYFEKn5FoSIVQLgT3I8MfI1\necdsa-sha2-nistp256"
612-
},
613-
"statistics": []
614-
}
615-
```
585+
```json
586+
{
587+
"id": 1,
588+
"hostkey": "SHA=cd4be31f20f0c7d019a5d3bfe368415f2d34fec8af26ee28c4c123c6a0af49a2",
589+
"api_url": "https://100.90.80.70",
590+
"ui_name": "feeder1",
591+
"role": "feeder",
592+
"target_state": "on",
593+
"transport": {
594+
"mode": "pull_over_rsync",
595+
"ssh_user": "cftransport",
596+
"ssh_host": "172.32.1.20",
597+
"ssh_pubkey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVGoBB3zLKfVTzDNum/JWlmNJrSuDGrhTW1ZGtZEKjxFViFr4j0F8s6gIr5KOMcWtd91XvW6klpCPqKH3lfY767AI/RQa8JgVXgtvUG8rkD+gJ/wzGJm+VoGpxxs9dyBgSOtkaOSIDc574Om8dBR8enRcgxo1cNpvDVLVYKx9IzqhBwqp1gzEtGoIi+CDoGmoj1BT9XTlCRvGXYmSSBrgLARVO2mh5iqhP0XRVCp9Ki6OB9vMcs9rxIgQaPt8tVCt7/FK03IXrWPUsJC4M/kXiaKgHlE96H0CEvYl7GczaIU2NN5AHXZlviL79Zb8kOcUzsMdKv40G9YVa7/kyDOUX root@ip-172-32-1-20",
598+
"ssh_fingerprint": "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBF18li5PyCyVy27+Lv09HDRxhyEnlL+zK++WaLc78W+Gji5i2VSRDg/jVV0xU2ZUmkohULZ66OmI5/sCOOIa3XU=\nssh-ed25519"
599+
},
600+
"statistics": []
601+
}
602+
{
603+
"id": 2,
604+
"hostkey": "SHA=30b6bb15fb94c9b7e386521bbe566934d266db2f6f63cd85f5e6fc406d11110b",
605+
"api_url": "https://100.90.80.60",
606+
"ui_name": "feeder2",
607+
"role": "feeder",
608+
"target_state": "on",
609+
"transport": {
610+
"mode": "pull_over_rsync",
611+
"ssh_user": "cftransport",
612+
"ssh_host": "172.32.1.21",
613+
"ssh_pubkey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDin59ffTXhtQxahrYkqNi3x36XIO08GnOvvVe3s+DmuT3kBn8Lh4P30kOVONSGKcfNZLnWVPrk2qqNWuEi6xg861G1kXqce02c26BW+4L/tnz86/kmTBGc2vb6d1NpEKA/1bg6bMf1da+EInxuMsS+yOWCe+s6DJ00bg6iCnmlLYtzAkMXmXK5QgVG6AImJXqG1Px5DlsRcKto00J8WJswfTpQXbZbuog4J6Ltm/J4DQW1/x7pEJby/r+/lKPJWp19t0gaGXfsxwHEPFK6YC8zmFzkBeqiVpAizhs7G8mZDgAAhMyY8d2eYIp+hDIFpfQA3aHHr0L7emsFeDa/rExt root@ip-172-32-1-21",
614+
"ssh_fingerprint": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7HE4qJfTLP9j02jZnkpTpUMCBiFzmAemgvIPcJjWJVNcawh1hpGSsWjw9EM1kwn7J6fWrjEkY8lTi2pNTnobL9qt+oQvwFqUvs5EZ8gAVIAyDjKE8GLckZRt8VGxLWMtOlBKaAmPBn0eFP6ToPqnPygJiiM05vKtxPui1xuCTrW+rXShtolUJLwwGH2APcDqjKAdZceQK4nybJzk4J1P77sJc+9IlHJCTpfj8AQEbh/Z3cHtNKauaz1mhDn5YT/QWwzKavGlqFSlSDwLXT2go6P6FoSaVYTV45V9l7q6ahEy3zEe7+7psMFVucS512qYFEKn5FoSIVQLgT3I8MfI1\necdsa-sha2-nistp256"
615+
},
616+
"statistics": []
617+
}
618+
```
616619

617-
Determine the id from the "id" property value and delete the remote hub. In this case
620+
* Determine the id from the "id" property value and delete the remote hub with the API. In this case
618621
we use the number "1".
619622

620-
```console
621-
$ curl -k -s -X DELETE -u admin:$PASSWORD https://$SUPERHUB/api/fr/remote-hub/1
622-
```
623+
```console
624+
root@superhub: ~# REMOTE_HUB_ID=1
625+
root@superhub: ~# curl -k -s -X DELETE -u admin:$PASSWORD https://$SUPERHUB/api/fr/remote-hub/$REMOTE_HUB_ID
626+
```
627+
628+
* Remove the feeder from `/opt/cfengine/federation/cfapache/federation-config.json`. Replace "id-1" below with the appropriate id from the previous steps.
629+
630+
```console
631+
root@superhub: ~# contents=$(jq 'del(.remote_hubs ."id-1")' /opt/cfengine/federation/cfapache/federation-config.json) && echo "${contents}" > /opt/cfengine/federation/cfapache/federation-config.json
632+
```
633+
634+
* Remove items associated with this feeder in the `cfdb` database.
635+
636+
Determine the cfdb-specific `hub_id`.
637+
638+
```console
639+
root@superhub: ~# /var/cfengine/bin/psql cfdb -c "select * from __hubs"
640+
```
641+
642+
Typical output would be like the following.
643+
644+
```
645+
hub_id | hostkey | last_import_ts
646+
--------+----------------------------------------------------------------------+----------------
647+
0 | SHA=50d370f41c81b3e119506befecc5deaa63c0f1d9039f674c68f9253a07f7ad84 |
648+
1 | SHA=bfd6f580f9d19cb190139452f068f38f843bf9227ca3515f7adfecfa39f68728 |
649+
(2 rows)
650+
```
651+
652+
`hub_id` of `0` is the superhub. The others are the feeders.
653+
In this case, it happens that the `hub_id` is also "1" so we will use that in the following queries.
654+
655+
* Execute the following commands to remove the namespace for that feeder as well as the entry in the `__hubs` table.
656+
657+
```console
658+
root@superhub: ~# /var/cfengine/bin/psql cfdb -c 'drop schema "hub_1" cascade;'
659+
root@superhub: ~# /var/cfengine/bin/psql cfdb -c "delete from __hubs where hub_id = 1"
660+
```
661+
662+
* On the feeder, replace `/opt/cfengine/federation/cfapache/federation-config.json` with the following content.
663+
664+
If you wish to re-add this feeder to a superhub, change "target_state" from "off" to "on".
665+
Remember to trigger or wait for an agent run for the change from off to on to take effect.
666+
667+
```json
668+
{
669+
"hostname": null,
670+
"role": "feeder",
671+
"target_state": "off",
672+
"remote_hubs": { }
673+
}
674+
```
675+
676+
677+
* On 3.15.x and greater feeders, also run the following commands to truncate two tables:
678+
679+
```console
680+
root@feeder: ~# /var/cfengine/bin/psql cfsettings -c 'TRUNCATE remote_hubs'
681+
root@feeder: ~# /var/cfengine/bin/psql cfsettings -c 'TRUNCATE federated_reporting_settings'
682+
```
623683

624684
## Superhub Upgrade ##
625685

0 commit comments

Comments
 (0)