Update docs for inventory_builder (#4581)
This commit is contained in:
parent
33ab615072
commit
12086744e0
|
@ -29,7 +29,7 @@ To deploy the cluster you can use :
|
||||||
|
|
||||||
# Update Ansible inventory file with inventory builder
|
# Update Ansible inventory file with inventory builder
|
||||||
declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
|
declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
|
||||||
CONFIG_FILE=inventory/mycluster/hosts.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]}
|
CONFIG_FILE=inventory/mycluster/hosts.yml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
|
||||||
|
|
||||||
# Review and change parameters under ``inventory/mycluster/group_vars``
|
# Review and change parameters under ``inventory/mycluster/group_vars``
|
||||||
cat inventory/mycluster/group_vars/all/all.yml
|
cat inventory/mycluster/group_vars/all/all.yml
|
||||||
|
@ -39,7 +39,7 @@ To deploy the cluster you can use :
|
||||||
# The option `-b` is required, as for example writing SSL keys in /etc/,
|
# The option `-b` is required, as for example writing SSL keys in /etc/,
|
||||||
# installing packages and interacting with various systemd daemons.
|
# installing packages and interacting with various systemd daemons.
|
||||||
# Without -b the playbook will fail to run!
|
# Without -b the playbook will fail to run!
|
||||||
ansible-playbook -i inventory/mycluster/hosts.ini --become --become-user=root cluster.yml
|
ansible-playbook -i inventory/mycluster/hosts.yml --become --become-user=root cluster.yml
|
||||||
|
|
||||||
Note: When Ansible is already installed via system packages on the control machine, other python packages installed via `sudo pip install -r requirements.txt` will go to a different directory tree (e.g. `/usr/local/lib/python2.7/dist-packages` on Ubuntu) from Ansible's (e.g. `/usr/lib/python2.7/dist-packages/ansible` still on Ubuntu).
|
Note: When Ansible is already installed via system packages on the control machine, other python packages installed via `sudo pip install -r requirements.txt` will go to a different directory tree (e.g. `/usr/local/lib/python2.7/dist-packages` on Ubuntu) from Ansible's (e.g. `/usr/lib/python2.7/dist-packages/ansible` still on Ubuntu).
|
||||||
As a consequence, `ansible-playbook` command will fail with:
|
As a consequence, `ansible-playbook` command will fail with:
|
||||||
|
|
|
@ -6,7 +6,7 @@ Building your own inventory
|
||||||
|
|
||||||
Ansible inventory can be stored in 3 formats: YAML, JSON, or INI-like. There is
|
Ansible inventory can be stored in 3 formats: YAML, JSON, or INI-like. There is
|
||||||
an example inventory located
|
an example inventory located
|
||||||
[here](https://github.com/kubernetes-sigs/kubespray/blob/master/inventory/sample/hosts.ini).
|
[here](https://github.com/kubernetes-sigs/kubespray/blob/master/inventory/sample/inventory.ini).
|
||||||
|
|
||||||
You can use an
|
You can use an
|
||||||
[inventory generator](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/inventory_builder/inventory.py)
|
[inventory generator](https://github.com/kubernetes-sigs/kubespray/blob/master/contrib/inventory_builder/inventory.py)
|
||||||
|
@ -20,7 +20,9 @@ Example inventory generator usage:
|
||||||
|
|
||||||
cp -r inventory/sample inventory/mycluster
|
cp -r inventory/sample inventory/mycluster
|
||||||
declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
|
declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
|
||||||
CONFIG_FILE=inventory/mycluster/hosts.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]}
|
CONFIG_FILE=inventory/mycluster/hosts.yml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
|
||||||
|
|
||||||
|
Then use `inventory/mycluster/hosts.yml` as inventory file.
|
||||||
|
|
||||||
Starting custom deployment
|
Starting custom deployment
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -30,7 +32,7 @@ and start the deployment:
|
||||||
|
|
||||||
**IMPORTANT**: Edit my\_inventory/groups\_vars/\*.yaml to override data vars:
|
**IMPORTANT**: Edit my\_inventory/groups\_vars/\*.yaml to override data vars:
|
||||||
|
|
||||||
ansible-playbook -i inventory/mycluster/hosts.ini cluster.yml -b -v \
|
ansible-playbook -i inventory/mycluster/hosts.yml cluster.yml -b -v \
|
||||||
--private-key=~/.ssh/private_key
|
--private-key=~/.ssh/private_key
|
||||||
|
|
||||||
See more details in the [ansible guide](ansible.md).
|
See more details in the [ansible guide](ansible.md).
|
||||||
|
@ -43,7 +45,7 @@ You may want to add worker, master or etcd nodes to your existing cluster. This
|
||||||
- Add the new worker node to your inventory in the appropriate group (or utilize a [dynamic inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html)).
|
- Add the new worker node to your inventory in the appropriate group (or utilize a [dynamic inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html)).
|
||||||
- Run the ansible-playbook command, substituting `cluster.yml` for `scale.yml`:
|
- Run the ansible-playbook command, substituting `cluster.yml` for `scale.yml`:
|
||||||
|
|
||||||
ansible-playbook -i inventory/mycluster/hosts.ini scale.yml -b -v \
|
ansible-playbook -i inventory/mycluster/hosts.yml scale.yml -b -v \
|
||||||
--private-key=~/.ssh/private_key
|
--private-key=~/.ssh/private_key
|
||||||
|
|
||||||
Remove nodes
|
Remove nodes
|
||||||
|
@ -53,12 +55,12 @@ You may want to remove **worker** nodes to your existing cluster. This can be do
|
||||||
|
|
||||||
Add worker nodes to the list under kube-node if you want to delete them (or utilize a [dynamic inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html)).
|
Add worker nodes to the list under kube-node if you want to delete them (or utilize a [dynamic inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html)).
|
||||||
|
|
||||||
ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v \
|
ansible-playbook -i inventory/mycluster/hosts.yml remove-node.yml -b -v \
|
||||||
--private-key=~/.ssh/private_key
|
--private-key=~/.ssh/private_key
|
||||||
|
|
||||||
Use `--extra-vars "node=<nodename>,<nodename2>"` to select the node you want to delete.
|
Use `--extra-vars "node=<nodename>,<nodename2>"` to select the node you want to delete.
|
||||||
```
|
```
|
||||||
ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v \
|
ansible-playbook -i inventory/mycluster/hosts.yml remove-node.yml -b -v \
|
||||||
--private-key=~/.ssh/private_key \
|
--private-key=~/.ssh/private_key \
|
||||||
--extra-vars "node=nodename,nodename2"
|
--extra-vars "node=nodename,nodename2"
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue