Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
2f03e0c9
Commit
2f03e0c9
authored
Nov 10, 2014
by
Matt Martz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support fallbacks for access network and access ip version
parent
b9b3c0de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
plugins/inventory/rax.ini
+4
-2
plugins/inventory/rax.py
+33
-20
No files found.
plugins/inventory/rax.ini
View file @
2f03e0c9
...
...
@@ -41,7 +41,8 @@
#
# A configuration that will tell the inventory script to use a specific
# server network to determine the ansible_ssh_host value. If no address
# is found, ansible_ssh_host will not be set.
# is found, ansible_ssh_host will not be set. Accepts a comma-separated
# list of network names, the first found wins.
# access_network = public
# Environment Variable: RAX_ACCESS_IP_VERSION
...
...
@@ -51,5 +52,6 @@
# determine the ansible_ssh_host value for either IPv4 or IPv6. If no
# address is found, ansible_ssh_host will not be set.
# Acceptable values are: 4 or 6. Values other than 4 or 6
# will be ignored, and 4 will be used.
# will be ignored, and 4 will be used. Accepts a comma separated list,
# the first found wins.
# access_ip_version = 4
plugins/inventory/rax.py
View file @
2f03e0c9
...
...
@@ -114,7 +114,8 @@ Configuration:
A configuration that will tell the inventory script to use a specific
server network to determine the ansible_ssh_host value. If no address
is found, ansible_ssh_host will not be set.
is found, ansible_ssh_host will not be set. Accepts a comma-separated
list of network names, the first found wins.
access_ip_version:
Environment Variable: RAX_ACCESS_IP_VERSION
...
...
@@ -124,7 +125,8 @@ Configuration:
determine the ansible_ssh_host value for either IPv4 or IPv6. If no
address is found, ansible_ssh_host will not be set.
Acceptable values are: 4 or 6. Values other than 4 or 6
will be ignored, and 4 will be used.
will be ignored, and 4 will be used. Accepts a comma-separated list,
the first found wins.
Examples:
List server instances
...
...
@@ -220,16 +222,18 @@ def _list(regions):
prefix
=
get_config
(
p
,
'rax'
,
'meta_prefix'
,
'RAX_META_PREFIX'
,
'meta'
)
network
=
get_config
(
p
,
'rax'
,
'access_network'
,
'RAX_ACCESS_NETWORK'
,
'public'
)
network
s
=
get_config
(
p
,
'rax'
,
'access_network'
,
'RAX_ACCESS_NETWORK'
,
'public'
,
islist
=
True
)
try
:
ip_version
=
get_config
(
p
,
'rax'
,
'access_ip_version'
,
'RAX_ACCESS_IP_VERSION'
,
4
,
integer
=
True
)
ip_versions
=
map
(
int
,
get_config
(
p
,
'rax'
,
'access_ip_version'
,
'RAX_ACCESS_IP_VERSION'
,
4
,
islist
=
True
))
except
:
ip_version
=
4
ip_version
s
=
[
4
]
else
:
if
ip_version
not
in
[
4
,
6
]:
ip_version
=
4
ip_versions
=
[
v
for
v
in
ip_versions
if
v
in
[
4
,
6
]]
if
not
ip_versions
:
ip_versions
=
[
4
]
# Go through all the regions looking for servers
for
region
in
regions
:
...
...
@@ -305,17 +309,26 @@ def _list(regions):
# And finally, add an IP address
ansible_ssh_host
=
None
# use accessIPv[46] instead of looping address for 'public'
if
network
==
'public'
:
if
ip_version
==
6
and
server
.
accessIPv6
:
ansible_ssh_host
=
server
.
accessIPv6
elif
server
.
accessIPv4
:
ansible_ssh_host
=
server
.
accessIPv4
else
:
addresses
=
server
.
addresses
.
get
(
network
,
[])
for
address
in
addresses
:
if
address
.
get
(
'version'
)
==
ip_version
:
ansible_ssh_host
=
address
.
get
(
'addr'
)
break
for
network_name
in
networks
:
if
ansible_ssh_host
:
break
if
network_name
==
'public'
:
for
version_name
in
ip_versions
:
if
ansible_ssh_host
:
break
if
version_name
==
6
and
server
.
accessIPv6
:
ansible_ssh_host
=
server
.
accessIPv6
elif
server
.
accessIPv4
:
ansible_ssh_host
=
server
.
accessIPv4
if
not
ansible_ssh_host
:
addresses
=
server
.
addresses
.
get
(
network_name
,
[])
for
address
in
addresses
:
for
version_name
in
ip_versions
:
if
ansible_ssh_host
:
break
if
address
.
get
(
'version'
)
==
version_name
:
ansible_ssh_host
=
address
.
get
(
'addr'
)
break
if
ansible_ssh_host
:
hostvars
[
server
.
name
][
'ansible_ssh_host'
]
=
ansible_ssh_host
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment