Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kubespray
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Kubespray
Commits
56523812
Commit
56523812
authored
5 years ago
by
Csergő Bálint
Committed by
Kubernetes Prow Robot
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
print hostnames (#5110)
parent
602b2d19
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/inventory_builder/inventory.py
+7
-1
7 additions, 1 deletion
contrib/inventory_builder/inventory.py
with
7 additions
and
1 deletion
contrib/inventory_builder/inventory.py
+
7
−
1
View file @
56523812
...
...
@@ -44,7 +44,7 @@ import sys
ROLES
=
[
'
all
'
,
'
kube-master
'
,
'
kube-node
'
,
'
etcd
'
,
'
k8s-cluster
'
,
'
calico-rr
'
]
PROTECTED_NAMES
=
ROLES
AVAILABLE_COMMANDS
=
[
'
help
'
,
'
print_cfg
'
,
'
print_ips
'
,
'
load
'
]
AVAILABLE_COMMANDS
=
[
'
help
'
,
'
print_cfg
'
,
'
print_ips
'
,
'
print_hostnames
'
,
'
load
'
]
_boolean_states
=
{
'
1
'
:
True
,
'
yes
'
:
True
,
'
true
'
:
True
,
'
on
'
:
True
,
'
0
'
:
False
,
'
no
'
:
False
,
'
false
'
:
False
,
'
off
'
:
False
}
yaml
=
YAML
()
...
...
@@ -348,6 +348,8 @@ class KubesprayInventory(object):
self
.
print_config
()
elif
command
==
'
print_ips
'
:
self
.
print_ips
()
elif
command
==
'
print_hostnames
'
:
self
.
print_hostnames
()
elif
command
==
'
load
'
:
self
.
load_file
(
args
)
else
:
...
...
@@ -361,6 +363,7 @@ Available commands:
help - Display this message
print_cfg - Write inventory file to stdout
print_ips - Write a space-delimited list of IPs from
"
all
"
group
print_hostnames - Write a space-delimited list of Hostnames from
"
all
"
group
Advanced usage:
Add another host after initial creation: inventory.py 10.10.1.5
...
...
@@ -381,6 +384,9 @@ MASSIVE_SCALE_THRESHOLD Separate K8s master and ETCD if # of nodes >= 200
def
print_config
(
self
):
yaml
.
dump
(
self
.
yaml_config
,
sys
.
stdout
)
def
print_hostnames
(
self
):
print
(
'
'
.
join
(
self
.
yaml_config
[
'
all
'
][
'
hosts
'
].
keys
()))
def
print_ips
(
self
):
ips
=
[]
for
host
,
opts
in
self
.
yaml_config
[
'
all
'
][
'
hosts
'
].
items
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment