|
| 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 | + |
1 | 49 | - block: |
2 | 50 |
|
3 | 51 | - name: 'Manage the networks for the VM' |
|
53 | 101 | fixed_ips: '{{ [{"ip_address": item["fixed_ip"]}] if item["fixed_ip"] is defined else omit }}' |
54 | 102 | # 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 |
55 | 103 | 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 }}' |
56 | 106 | state: 'present' |
57 | 107 | delegate_to: 'localhost' |
58 | 108 | loop: '{{ infomaniak_vm__networks }}' |
|
70 | 120 | - 'infomaniak_vm:networks' |
71 | 121 |
|
72 | 122 |
|
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 | | - |
121 | 123 | - block: |
122 | 124 |
|
123 | 125 | - name: 'Manage the boot volume for the VM' |
|
0 commit comments