Generate a config file based on Ansible inventories
curl -ssf -L https://raw.githubusercontent.com/ca-gip/gensshconfig/master/install.sh | bashYou will need go v1.15
go build -o gensshconfig main.goGeneration works for project that use the following inventory layout
inventories
├── common_vars
│ ├── all.yml
│ └── all_vault.yml
└── os
├── client_one_hp
│ ├── group_vars
│ └── hosts.ini
├── client_one_prd
│ ├── group_vars
│ └── hosts.ini
├── client_three_hp
│ ├── group_vars
│ └── hosts.ini
├── client_three_prd
│ ├── group_vars
│ └── hosts.ini
├── client_two_hp
│ ├── group_vars
│ └── hosts.ini
└── client_two_prd
├── group_vars
└── hosts.inigensshconfig --user $USER_BASTION --bastion $IP_BASTION --inventory ~/Projects/ansible-kube/inventories/osgensshconfig --user $USER_BASTION --bastion $IP_BASTION --inventory ~/Projects/ansible-kube/inventories/os > ~/.ssh/k8s_configIf you do not want to overwrite the default config like in the above exmaple, do not forget to include the following line in your main config file
Include k8s_config
To see the available parameters
gensshconfig -h
| Name | Description | Mandatory | Type |
|---|---|---|---|
| bastion | IP Address of the bastion | yes |
String |
| inventory | Inventory folder to extract clusters host | yes |
String |
| user | User for the bastion | yes |
String |