mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-12-12 21:42:35 +00:00
Fix inventory plugin does not work with old configuration files (#15)
This commit is contained in:
parent
d795d331e7
commit
41354355e6
7 changed files with 15 additions and 9 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfix:
|
||||||
|
- hcloud inventory plugin - Allow usage of hcloud.yml and hcloud.yaml - this was removed by error within the migration from build-in ansible to our collection
|
|
@ -230,7 +230,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
"""Return the possibly of a file being consumable by this plugin."""
|
"""Return the possibly of a file being consumable by this plugin."""
|
||||||
return (
|
return (
|
||||||
super(InventoryModule, self).verify_file(path) and
|
super(InventoryModule, self).verify_file(path) and
|
||||||
path.endswith((self.NAME + ".yaml", self.NAME + ".yml"))
|
path.endswith(("hcloud.yaml", "hcloud.yml"))
|
||||||
)
|
)
|
||||||
|
|
||||||
def parse(self, inventory, loader, path, cache=True):
|
def parse(self, inventory, loader, path, cache=True):
|
||||||
|
|
|
@ -174,7 +174,7 @@ class AnsibleHcloudLoadBalancer(Hcloud):
|
||||||
"location": to_native(self.hcloud_load_balancer.location.name),
|
"location": to_native(self.hcloud_load_balancer.location.name),
|
||||||
"labels": self.hcloud_load_balancer.labels,
|
"labels": self.hcloud_load_balancer.labels,
|
||||||
"delete_protection": self.hcloud_load_balancer.protection["delete"],
|
"delete_protection": self.hcloud_load_balancer.protection["delete"],
|
||||||
"disable_public_interface": self.hcloud_load_balancer.public_net.enabled
|
"disable_public_interface": False if self.hcloud_load_balancer.public_net.enabled else True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_load_balancer(self):
|
def _get_load_balancer(self):
|
||||||
|
@ -219,7 +219,6 @@ class AnsibleHcloudLoadBalancer(Hcloud):
|
||||||
|
|
||||||
self._mark_as_changed()
|
self._mark_as_changed()
|
||||||
self._get_load_balancer()
|
self._get_load_balancer()
|
||||||
self._update_load_balancer()
|
|
||||||
|
|
||||||
def _update_load_balancer(self):
|
def _update_load_balancer(self):
|
||||||
try:
|
try:
|
||||||
|
@ -237,7 +236,7 @@ class AnsibleHcloudLoadBalancer(Hcloud):
|
||||||
self._get_load_balancer()
|
self._get_load_balancer()
|
||||||
|
|
||||||
disable_public_interface = self.module.params.get("disable_public_interface")
|
disable_public_interface = self.module.params.get("disable_public_interface")
|
||||||
if disable_public_interface is not None and disable_public_interface != self.hcloud_load_balancer.public_net.enabled:
|
if disable_public_interface is not None and disable_public_interface != (not self.hcloud_load_balancer.public_net.enabled):
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
if disable_public_interface is True:
|
if disable_public_interface is True:
|
||||||
self.hcloud_load_balancer.disable_public_interface().wait_until_finished()
|
self.hcloud_load_balancer.disable_public_interface().wait_until_finished()
|
||||||
|
@ -277,7 +276,7 @@ class AnsibleHcloudLoadBalancer(Hcloud):
|
||||||
network_zone={"type": "str"},
|
network_zone={"type": "str"},
|
||||||
labels={"type": "dict"},
|
labels={"type": "dict"},
|
||||||
delete_protection={"type": "bool"},
|
delete_protection={"type": "bool"},
|
||||||
disable_public_interface={"type": "bool", "default": False},
|
disable_public_interface={"type": "bool"},
|
||||||
state={
|
state={
|
||||||
"choices": ["absent", "present"],
|
"choices": ["absent", "present"],
|
||||||
"default": "present",
|
"default": "present",
|
||||||
|
|
|
@ -322,7 +322,7 @@ class AnsibleHcloudLoadBalancerService(Hcloud):
|
||||||
"response": to_native(self.hcloud_load_balancer_service.health_check.http.response),
|
"response": to_native(self.hcloud_load_balancer_service.health_check.http.response),
|
||||||
"certificates": [to_native(status_code) for status_code in
|
"certificates": [to_native(status_code) for status_code in
|
||||||
self.hcloud_load_balancer_service.health_check.http.status_codes],
|
self.hcloud_load_balancer_service.health_check.http.status_codes],
|
||||||
"tls": self.hcloud_load_balancer_service.health_check.tls,
|
"tls": self.hcloud_load_balancer_service.health_check.http.tls,
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
"load_balancer": to_native(self.hcloud_load_balancer.name),
|
"load_balancer": to_native(self.hcloud_load_balancer.name),
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
- name: test create Load Balancer Load Balancer
|
- name: test create Load Balancer with check mode
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -51,6 +51,8 @@
|
||||||
- name: test create Load Balancer idempotence
|
- name: test create Load Balancer idempotence
|
||||||
hcloud_load_balancer:
|
hcloud_load_balancer:
|
||||||
name: "{{ hcloud_load_balancer_name }}"
|
name: "{{ hcloud_load_balancer_name }}"
|
||||||
|
load_balancer_type: lb11
|
||||||
|
network_zone: eu-central
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
- name: verify create Load Balancer idempotence
|
- name: verify create Load Balancer idempotence
|
||||||
|
|
|
@ -46,6 +46,7 @@ fi
|
||||||
export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
|
export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
|
||||||
SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
|
SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
|
||||||
TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud"
|
TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/hetzner/hcloud"
|
||||||
|
rm -rf "${TEST_DIR}"
|
||||||
mkdir -p "${TEST_DIR}"
|
mkdir -p "${TEST_DIR}"
|
||||||
cp -r "." "${TEST_DIR}"
|
cp -r "." "${TEST_DIR}"
|
||||||
cd "${TEST_DIR}"
|
cd "${TEST_DIR}"
|
||||||
|
@ -85,7 +86,9 @@ find plugins -type d -empty -print -delete
|
||||||
ansible-test env --dump --show --timeout "50" --color -v
|
ansible-test env --dump --show --timeout "50" --color -v
|
||||||
|
|
||||||
group="${args[1]}"
|
group="${args[1]}"
|
||||||
if [[ "${test}" =~ integration ]]; then
|
echo $test
|
||||||
|
if [[ "${test}" =~ hcloud ]]; then
|
||||||
|
group="${args[3]}"
|
||||||
bash tests/utils/gitlab/integration.sh "shippable/hcloud/group${group}/"
|
bash tests/utils/gitlab/integration.sh "shippable/hcloud/group${group}/"
|
||||||
else
|
else
|
||||||
bash tests/utils/gitlab/sanity.sh "sanity/${group}"
|
bash tests/utils/gitlab/sanity.sh "sanity/${group}"
|
||||||
|
|
|
@ -12,4 +12,4 @@ hcloud_api_token=${HCLOUD_TOKEN}
|
||||||
export SHIPPABLE="true"
|
export SHIPPABLE="true"
|
||||||
export SHIPPABLE_BUILD_NUMBER="gl-$(cat prefix.txt)"
|
export SHIPPABLE_BUILD_NUMBER="gl-$(cat prefix.txt)"
|
||||||
export SHIPPABLE_JOB_NUMBER="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)"
|
export SHIPPABLE_JOB_NUMBER="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1)"
|
||||||
ansible-test integration --color --local -vvvvv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"}
|
ansible-test integration --color --local -vv "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"}
|
||||||
|
|
Loading…
Reference in a new issue