Skip to content

Commit fb377d6

Browse files
committed
fix(roles/infomaniak_vm): correctly apply security group on the named ext-net1 port
1 parent 8c2b008 commit fb377d6

2 files changed

Lines changed: 51 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525

2626
### Fixed
2727

28+
* **role:infomaniak_vm**: Apply the VM's security group on the `ext-net1` port instead of (only) on the server. When a VM boots against a pre-created port, Neutron enforces the port's security groups, not those passed to the server, so without this the configured rules were silently ignored on the public interface
2829
* **role:logstash**: Default value of `logstash__java_opts` now caps JVM heap size at 8g.
2930
* **role:logstash**: Default value of `logstash__java_opts` now sets JVM heap size to be 60% of total memory.
3031
* **role:graylog_datanode**: Validate that `graylog_datanode__password_secret | length >= 16`

roles/infomaniak_vm/tasks/main.yml

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
- block:
2+
3+
- name: 'Manage the security group for the VM'
4+
openstack.cloud.security_group:
5+
auth:
6+
auth_url: 'https://api.pub1.infomaniak.cloud/identity/v3'
7+
username: '{{ infomaniak_vm__api_username }}'
8+
password: '{{ infomaniak_vm__api_password }}'
9+
project_id: '{{ infomaniak_vm__api_project_id }}'
10+
project_name: '{{ infomaniak_vm__api_username }}'
11+
user_domain_name: 'default'
12+
region_name: '{{ infomaniak_vm__region_name }}'
13+
name: '{{ infomaniak_vm__name }}'
14+
state: 'present'
15+
delegate_to: 'localhost'
16+
when:
17+
- 'infomaniak_vm__security_group_rules is defined and infomaniak_vm__security_group_rules | length > 0'
18+
- 'infomaniak_vm__state != "absent"'
19+
20+
- name: 'Manage the required security group rules for the VM'
21+
openstack.cloud.security_group_rule:
22+
auth:
23+
auth_url: 'https://api.pub1.infomaniak.cloud/identity/v3'
24+
username: '{{ infomaniak_vm__api_username }}'
25+
password: '{{ infomaniak_vm__api_password }}'
26+
project_id: '{{ infomaniak_vm__api_project_id }}'
27+
project_name: '{{ infomaniak_vm__api_username }}'
28+
user_domain_name: 'default'
29+
region_name: '{{ infomaniak_vm__region_name }}'
30+
security_group: '{{ infomaniak_vm__name }}'
31+
direction: '{{ item["direction"] | default("ingress") }}'
32+
protocol: '{{ item["protocol"] | default(omit) }}'
33+
port_range_min: '{{ item["port_range_min"] | default(omit) }}'
34+
port_range_max: '{{ item["port_range_max"] | default(omit) }}'
35+
remote_ip_prefix: '{{ item["remote_ip_prefix"] | default(omit) }}'
36+
ethertype: '{{ item["ethertype"] | default("IPv4") }}'
37+
state: '{{ item["state"] | d("present") }}'
38+
loop: '{{ infomaniak_vm__security_group_rules }}'
39+
delegate_to: 'localhost'
40+
when:
41+
- 'infomaniak_vm__security_group_rules is defined and infomaniak_vm__security_group_rules | length > 0'
42+
- 'infomaniak_vm__state != "absent"'
43+
44+
tags:
45+
- 'infomaniak_vm'
46+
- 'infomaniak_vm:firewalls'
47+
48+
149
- block:
250

351
- name: 'Manage the networks for the VM'
@@ -53,6 +101,8 @@
53101
fixed_ips: '{{ [{"ip_address": item["fixed_ip"]}] if item["fixed_ip"] is defined else omit }}'
54102
# Infomaniak's Neutron policy forbids setting `port_security_enabled` on the public `ext-net1` network, so omit it there and let the cloud default apply. On every other network, disable port security — this is a sensible default for internal networks
55103
port_security_enabled: '{{ omit if item["name"] == "ext-net1" else false }}'
104+
# When a VM boots against a pre-created port, Neutron enforces the port's security groups, not the ones passed to `openstack.cloud.server`. Assign them here so `ext-net1` traffic is filtered. On internal networks port security is disabled, so security groups don't apply — omit to keep Neutron quiet.
105+
security_groups: '{{ ((infomaniak_vm__security_group_rules is defined and infomaniak_vm__security_group_rules | length > 0) | ternary(["default", infomaniak_vm__name], ["default"])) if item["name"] == "ext-net1" else omit }}'
56106
state: 'present'
57107
delegate_to: 'localhost'
58108
loop: '{{ infomaniak_vm__networks }}'
@@ -70,54 +120,6 @@
70120
- 'infomaniak_vm:networks'
71121

72122

73-
- block:
74-
75-
- name: 'Manage the security group for the VM'
76-
openstack.cloud.security_group:
77-
auth:
78-
auth_url: 'https://api.pub1.infomaniak.cloud/identity/v3'
79-
username: '{{ infomaniak_vm__api_username }}'
80-
password: '{{ infomaniak_vm__api_password }}'
81-
project_id: '{{ infomaniak_vm__api_project_id }}'
82-
project_name: '{{ infomaniak_vm__api_username }}'
83-
user_domain_name: 'default'
84-
region_name: '{{ infomaniak_vm__region_name }}'
85-
name: '{{ infomaniak_vm__name }}'
86-
state: 'present'
87-
delegate_to: 'localhost'
88-
when:
89-
- 'infomaniak_vm__security_group_rules is defined and infomaniak_vm__security_group_rules | length > 0'
90-
- 'infomaniak_vm__state != "absent"'
91-
92-
- name: 'Manage the required security group rules for the VM'
93-
openstack.cloud.security_group_rule:
94-
auth:
95-
auth_url: 'https://api.pub1.infomaniak.cloud/identity/v3'
96-
username: '{{ infomaniak_vm__api_username }}'
97-
password: '{{ infomaniak_vm__api_password }}'
98-
project_id: '{{ infomaniak_vm__api_project_id }}'
99-
project_name: '{{ infomaniak_vm__api_username }}'
100-
user_domain_name: 'default'
101-
region_name: '{{ infomaniak_vm__region_name }}'
102-
security_group: '{{ infomaniak_vm__name }}'
103-
direction: '{{ item["direction"] | default("ingress") }}'
104-
protocol: '{{ item["protocol"] | default(omit) }}'
105-
port_range_min: '{{ item["port_range_min"] | default(omit) }}'
106-
port_range_max: '{{ item["port_range_max"] | default(omit) }}'
107-
remote_ip_prefix: '{{ item["remote_ip_prefix"] | default(omit) }}'
108-
ethertype: '{{ item["ethertype"] | default("IPv4") }}'
109-
state: '{{ item["state"] | d("present") }}'
110-
loop: '{{ infomaniak_vm__security_group_rules }}'
111-
delegate_to: 'localhost'
112-
when:
113-
- 'infomaniak_vm__security_group_rules is defined and infomaniak_vm__security_group_rules | length > 0'
114-
- 'infomaniak_vm__state != "absent"'
115-
116-
tags:
117-
- 'infomaniak_vm'
118-
- 'infomaniak_vm:firewalls'
119-
120-
121123
- block:
122124

123125
- name: 'Manage the boot volume for the VM'

0 commit comments

Comments
 (0)