how to set disks config and interfaces config via ansible?
Hello,
I have 2 ansible playbook that works :
- 1 manage disk and boot options
- 1 manage interfaces and set vlan
Each one works, but when I'm trying to mix them to get both disks and interfaces set up at the same time, it fails with the following message :
FAILED! => {"changed": false, "msg": "parameters are mutually exclusive: interfaces|configs, interfaces|disks"}
Can someone help me with this?
Here is the first playbook (at least the linode creation part of it) :
The point is to have a 4GB swap disk.
- name: Create Linode Instance
hosts: localhost
tasks:
- name: Create linode
linode.cloud.instance:
api_token: xxx
label: node1
type: g6-nanode-1
region: fr-par
disks:
- label: root
image: linode/rocky8
root_pass: yolo
size: 21504
filesystem: ext4
authorized_keys: ['/root/ssh.pub']
- label: swap
filesystem: swap
size: 4096
configs:
- label: boot-config
root_device: /dev/sda
devices:
sda:
disk_label: root
sdb:
disk_label: swap
tags:
- my_project
state: present
booted: true
register: my_node
Here is the second one that creates a linode with 2 interfaces : the regular one with public ip and a 2nd one in a vlan
- name: Create Linode Instance
hosts: localhost
tasks:
- name: Create linode
linode.cloud.instance:
api_token: xxx
label: node1
type: g6-nanode-1
region: fr-par
image: linode/rocky8
root_pass: yolo
authorized_keys: ['/root/ssh.pub']
interfaces:
- purpose: "public"
- purpose: "vlan"
ipam_address: "192.168.168.17/24"
label: vlan1
tags:
- my_project
state: present
booted: true
register: my_node
And if I try to mix them (disk config + interfaces) like this it fails :
- name: Create Linode Instance
hosts: localhost
tasks:
- name: Create linode
linode.cloud.instance:
api_token: xxx
label: node1
type: g6-nanode-1
region: fr-par
disks:
- label: root
image: linode/rocky8
root_pass: yolo
size: 21504
filesystem: ext4
authorized_keys: ['/root/ssh.pub']
- label: swap
filesystem: swap
size: 4096
configs:
- label: boot-config
root_device: /dev/sda
devices:
sda:
disk_label: root
sdb:
disk_label: swap
interfaces:
- purpose: "public"
- purpose: "vlan"
ipam_address: "192.168.168.13/24"
label: vlan1
tags:
- my_project
state: present
booted: true
register: my_node
EDIT : maybe it's worth to say : I would like to create a linode instance with :
- a swap disk of 4GB
- 2 interfaces : 1 with public IP, and 1 connected to a vlan with a private IP I set.
2 Replies
✓ Best Answer
I found this answer to an not directly related question on our Community Site that seems to show a working configuration that achieves your goals there:
- name: Create Linode Instance
hosts: localhost
tasks:
- name: Create Linode server
linode.cloud.instance:
api_token: '$my-token'
label: 'django-test'
region: 'us-east'
type: 'g6-standard-1'
booted: true
private_ip: true
boot_config_label: boot-config
state: present
disks:
- label: boot
image: linode/ubuntu22.04
size: 20000
root_pass: '$my-password'
stackscript_id: '609175'
stackscript_data:
variable: {"user_name": "tlambert", "disable_root": "No", "soa_email_address": "$my-email-address@example.com", "django_user": "tlambert"}
- label: logs
size: 4000
filesystem: ext4
- label: swap
size: 512
filesystem: swap
configs:
- label: boot-config
root_device: /dev/sda
devices:
sda:
disk_label: boot
sdb:
disk_label: logs
sdc:
disk_label: swap
interfaces:
- purpose: public
primary: True
- purpose: vlan
label: Primary
ipam_address: "10.0.0.1/24"
state: present
Looking at how that differs from yours, it looks like Tim used interfaces as a suboption of configs rather than a separate parameter, which would make sense based on our GitHub documentation about this.
While Tim is using a StackScript there so it's a bit different, I do think this suggests that you should be able to create the specific disks and interfaces you want with some changes to your playbook.