Creating nodebalancer using ansible.cloud.nodebalancer rant and questions.

Hi all,
Trying to automate the creation of a nodebalancer with two (or more) linodes behind it. I'm using Ansible 2.9.6 (yes, I should upgrade!) and linode-cli 5.17.2 build of spec version 4.118.0 to do the work.

I installed linode.cloud using Ansible-galaxy like this:

ansible-galaxy collection install linode.cloud

But now I'm running into a question of either Ansible or linode.cloud and how to build a nodebalancer with a variable number of nodes (and configs, but that's a seperate issue for now). I ask this because the task:


  • name: Create a Linode NodeBalancer linode.cloud.nodebalancer: label: "{{ nb_label }}" region: "{{ nb_region }}" tags: nb_tags state: present configs:
    • port: "{{ config_port }} protocol: http algorithm: roundrobin nodes:
      • label: "my-node1"
        address: "192.168.x.y:{{ config_port }}"
        # This option doesn't exist!
        state: present

Doesn't work or seem to exist. So it's hard to know how you would add/remove/update nodes in a configuration. Especially if I'm adding multiple nodes.

Can I do a loop in this task? Can I build a hash/array of nodes to add, and then pass them in to have them added? The entire way nodebalancers are constructed in the API is a bit frustrating, since I would expect there to be three different steps to build things, since the linode-cli takes three steps:

linode-cli nodebalancer create ….
linode-cli nodebalancer config-create <nb_id> ….
linode-cli nodebalancer node-create <nb_id> <cfg_id> …</cfg_id></nb_id></nb_id>

So I would have expected the Ansible role to use the same distinctions, where you have to register the vars you use in the next step, and which would allow for easier looping, though still frustrating since you'd probably need a nb.yml, nb-configs.yml, nb-nodes.yml so you can loop over included tasks files to actually build things.

I can already build a variable number of linodes from one task by looping over things, now how would I do this for nodes in a nodebalancer config?

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct