Generate a config file based on Ansible
inventories
curl -ssf -L https://raw.githubusercontent.com/ca-gip/gensshconfig/master/install.sh | bash
You will need go v1.15
go build -o gensshconfig main.go
Generation 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.ini
gensshconfig --user $USER_BASTION --bastion $IP_BASTION --inventory ~/Projects/ansible-kube/inventories/os
gensshconfig --user $USER_BASTION --bastion $IP_BASTION --inventory ~/Projects/ansible-kube/inventories/os > ~/.ssh/k8s_config
If 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 |