Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaleway inventory: allows to connect via private IP #44342

Merged
merged 2 commits into from
Aug 29, 2018

Conversation

pilou-
Copy link
Contributor

@pilou- pilou- commented Aug 18, 2018

SUMMARY

ansible_host value was hardcoded with public IPv4 address.

With this PR:

  • private IPv4 or public IPv6 can be used

  • by default ansible_host isn't defined (then inventory_hostname is used, meaning value of hostnames parameter)

  • other host variables can be defined, values of these variables are templates which can reference data send by Scaleway API:

    plugin: scaleway
    hostnames:
      - hostname
    variables:
      ansible_host: private_ip
      state: state
      image: image.name
    regions:
      - ams1

    inventory will look like:

        {
            "_meta": {
                "hostvars": {
                    "testhost": {
                        "ansible_host": "10.1.1.1",
                        "arch": "x86_64",
                        "commercial_type": "START1-M",
                        "hostname": "testhost",
                        "id": "af669464-0c74-4c89-8573-9fe763028448",
                        "image": "CentOS 7.4",
                        "organization": "2cc9a115-380d-4ac0-ba4b-8947eee71325",
                        "public_ipv4": "163.172.1.1",
                        "public_ipv6": "2001:bc8::1",
                        "state": "running",
                        "tags": [
                            "testtag"
                        ]
                    }
                }
            },
            [...]
        }
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/plugins/inventory/scaleway.py

ANSIBLE VERSION
ansible 2.7.0.dev0 (devel bb553f138b) last updated 2018/08/15 01:37:30 (GMT +200)

ansible_host was hardcoded and it was not possible to connect using
private addresses.
This allows to define multiple host variables, values are templates
which can use hosts details send by API. For example this config file
use private address and defines two variables:

    plugin: scaleway
    hostnames:
      - hostname
    variables:
      ansible_host: private_ip
      state: state
      image: image.name
    regions:
      - ams1

inventory will looks like:

    {
        "_meta": {
            "hostvars": {
                "testhost": {
                    "ansible_host": "10.1.1.1",
                    "arch": "x86_64",
                    "commercial_type": "START1-M",
                    "hostname": "testhost",
                    "id": "af669464-0c74-4c89-8573-9fe763028448",
                    "image": "CentOS 7.4",
                    "organization": "2cc9a115-380d-4ac0-ba4b-8947eee71325",
                    "public_ipv4": "163.172.1.1",
                    "public_ipv6": "2001:bc8::1",
                    "state": "running",
                    "tags": [
                        "testtag"
                    ]
                }
            }
        },
        [...]
    }
@ansibot
Copy link
Contributor

ansibot commented Aug 18, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 cloud feature This issue/PR relates to a feature request. inventory Inventory category needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 18, 2018
@remyleone
Copy link
Contributor

LGTM

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Aug 19, 2018
@Spredzy
Copy link
Contributor

Spredzy commented Aug 20, 2018

shipit

@ansibot ansibot added the shipit This PR is ready to be merged by Core label Aug 20, 2018
@pilou-
Copy link
Contributor Author

pilou- commented Aug 27, 2018

bot_status

@ansibot
Copy link
Contributor

ansibot commented Aug 27, 2018

Components

lib/ansible/plugins/inventory/scaleway.py
support: community
maintainers: Spredzy hekonsek sieben

Metadata

waiting_on: maintainer
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
too many files or commits: False
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 1
community_shipits (namespace maintainers): 0
ansible_shipits (core team members): 1
shipit_actors (maintainers or core team members): sieben Spredzy
shipit_actors_other: []
automerge: automerge is_module test failed

click here for bot help

@ansibot ansibot added scaleway support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 27, 2018
@maxamillion
Copy link
Contributor

shipit

1 similar comment
@remyleone
Copy link
Contributor

shipit

@maxamillion
Copy link
Contributor

rebuild_merge

@ansibot ansibot merged commit c07ba82 into ansible:devel Aug 29, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 cloud feature This issue/PR relates to a feature request. inventory Inventory category scaleway shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants