Skip to content

Comments

Create role to deploy and configure MAAS#788

Open
falcocer-ibm wants to merge 6 commits intomainfrom
wip-maas-apt
Open

Create role to deploy and configure MAAS#788
falcocer-ibm wants to merge 6 commits intomainfrom
wip-maas-apt

Conversation

@falcocer-ibm
Copy link
Contributor

No description provided.

@falcocer-ibm falcocer-ibm requested a review from dmick September 17, 2025 16:36
@falcocer-ibm falcocer-ibm self-assigned this Sep 17, 2025
Signed-off-by: Fernando <fernando.alcocer.ochoa@ibm.com>
Signed-off-by: Fernando <fernando.alcocer.ochoa@ibm.com>
@dmick dmick changed the title Creating a new role to deploy and configure MAAS Create role to deploy and configure MAAS Sep 24, 2025
@@ -9,6 +9,7 @@ postgres_version: "16"
maas_version: "3.6"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit message: this is a "task", not a module

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will squash all my commits later.

existing_end_ips: "{{ ip_ranges_raw.stdout | from_json | map(attribute='end_ip') | list }}"

- name: Create IP Range for {{ subnet_name }} subnet
command: "maas {{ maas_admin_username }} ipranges create type={{ subnet_data.ip_range_type }} start_ip={{ subnet_data.start_ip }} end_ip={{ subnet_data.end_ip }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subnet= is also required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am re-configuring all the DHCP task, because right now for our needs is useless.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you reconfigure the tasks?

Comment on lines +13 to +14
existing_start_ips: "{{ ip_ranges_raw.stdout | from_json | map(attribute='start_ip') | list }}"
existing_end_ips: "{{ ip_ranges_raw.stdout | from_json | map(attribute='end_ip') | list }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the design decision behind this? Why not search for the cidr in maas admin ipranges read output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am re-configuring all the DHCP task, because right now for our needs is useless.


# This section verifies if the snippets already exist and creates the name variables
- name: Get current snippet names
command: bash -c "maas {{ maas_admin_username }} dhcpsnippets read"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not shell module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am re-configuring all the DHCP task, because right now for our needs is useless.

@djgalloway
Copy link
Contributor

The README should mention that the MAAS server should have a network interface on every subnet prior to running the playbook. And why.

@djgalloway
Copy link
Contributor

The ansible should handle:

  • Removing a reserved IP range from maas if it used to be in dhcp_maas_subnets: {} and isn't anymore

vlan_id: "{{ (subnet_info.stdout | from_json).id }}"

- name: Enable DHCP on {{ subnet_name }} subnet
command: "maas {{ maas_admin_username }} vlan update {{ fabric_name }} {{ vlan_vid }} dhcp_on=True primary_rack={{ groups['maas_region_rack_server'][0].split('.')[0] }} secondary_rack={{ groups['maas_rack_server'][0].split('.')[0] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primary_rack={{ groups['maas_region_rack_server'][0].split('.')[0] }} secondary_rack={{ groups['maas_rack_server'][0].split('.')[0] }}

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I configured this playbook to run on at least 2 MAAS servers in order to have HA, that command enables DHCP on the region controller but in order to do the same on the secondary rack you need to run the command specifying the secondary rack.

mode: '0644'

- name: Check curtin scripts directory
shell: "ls {{ maas_home_dir }}/usr/lib/python3/dist-packages/curtin/commands/install_grub.py"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stat module would be more appropriate

94_configure_sudo: ["curtin", "in-target", "--", "sh", "-c", "printf '%%sudo ALL=(ALL) NOPASSWD: ALL\nDefaults !requiretty\nDefaults visiblepw' >> /etc/sudoers.d/cephlab_sudo"]
96_create_ssh_directory: ["curtin", "in-target", "--", "sh", "-c", "mkdir -p /home/cm/.ssh"]
98_copy_ssh_keys_cm: ["curtin", "in-target", "--", "sh", "-c", "echo '{{ cm_user_ssh_keys|join('\n') }}' >> /home/cm/.ssh/authorized_keys"]
block: |2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change the indent level and add this weird indent-removal character?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add the block inside the curtin script you need to use the exact indent level the file already has otherwise curtin will ignore those commands.

@@ -49,15 +49,13 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these changes in this commit? config_maas.yml existed before the addition of console=, yes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end I will just squash all my commits together, but you are right, I will try to separate my commits better in order to do this review process easier.

when: "maas_install_method == 'snap' and not maas_x1.stat.exists"
register: maas_snap

- name: Unsquahs MAAS FS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsquash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs fixing

Signed-off-by: Fernando <fernando.alcocer.ochoa@ibm.com>
…hings and things that were added with the latest tasks.

Signed-off-by: Fernando <fernando.alcocer.ochoa@ibm.com>
@djgalloway
Copy link
Contributor

@falcocer-ibm is this ready to go now?

… of shell commands for improved reliability and clarity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants