Documentation for the collection.
ansible-playbook -i inventory sample.yml
Ansible Collection for interacting with MAAS
License: GNU General Public License v3.0
The inventory integration tests assert a machine is in a commissioning state after being added. This won't always work as the machine can transition to ready before ansible gets to that test.
I am working with getting the collection setup in AWX as part of a plugin/dynamic inventory. Currently will not work due to collection namespace being maas/maas, but inventory is searching namespace of canonical/maas.
To reproduce:
collections:
maas_invnentory.yml ->
plugin: "canonical.maas.inventory"
specifies unknown plugin 'canonical.maas.inventory
If I create softlink in .ansible/collections/ansible_collections of canonical-> maas, then everything works as expected. NOTE: debug was done outside of AWX to trackdown.
As a result of the broken integration tests new features cannot be tested and merged to main branch.
Tests should be fixed, CI should recover and the development of the Ansible collection should be resumed
When attempting to create a new interface via maas.maas.network_interface_physical
, the following error is thrown but the interface is created within MaaS.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'to_ansible'
fatal: [localhost]: FAILED! => changed=false
module_stderr: |-
Traceback (most recent call last):
File "/home/quinnm/.ansible/tmp/ansible-tmp-1690854602.0611262-30070-168320862924394/AnsiballZ_network_interface_physical.py", line 107, in <module>
_ansiballz_main()
File "/home/quinnm/.ansible/tmp/ansible-tmp-1690854602.0611262-30070-168320862924394/AnsiballZ_network_interface_physical.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/quinnm/.ansible/tmp/ansible-tmp-1690854602.0611262-30070-168320862924394/AnsiballZ_network_interface_physical.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.maas.maas.plugins.modules.network_interface_physical', init_globals=dict(_module_fqn='ansible_collections.maas.maas.plugins.modules.network_interface_physical', _modlib_path=modlib_path),
File "/usr/lib/python3.10/runpy.py", line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 259, in <module>
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 252, in main
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 210, in run
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 154, in ensure_present
AttributeError: 'NoneType' object has no attribute 'to_ansible'
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
Using the following task, I was attempting to create a new interface on a test system that had a status of Ready
in MaaS
- name: Create Interface
maas.maas.network_interface_physical:
cluster_instance:
host: "{{ maas_api_host }}"
token_key: "{{ maas_api_token_key }}"
token_secret: "{{ maas_api_token_secret }}"
customer_key: "{{ maas_api_customer_key }}"
machine: "{{ maas_machine_name }}.{{ maas_machine_domain }}"
state: present
mac_address: "{{ mac_address }}"
vlan: 5001
name: "eno1"
register: nic_info
In my debugging (aka lots of print statements ๐ ) I've found that for whatever reason, when this tries to run
after = updated_machine_obj.find_nic_by_mac(
new_nic_obj.mac_address
).to_ansible()
The function updated_machine_obj.find_nic_by_mac()
is returning None
.
Initial thought was "Maybe this is happening to quick and find_nic_by_mac()
is running before the API has the new Nic info recorded. After injecting some time between creation and lookup, I don't think this is the case.
I'm still poking around on this one, but so far I've not stumbled into the solution.
The tests expect certain vm hosts to exist so that machines can be created for the test environment.
However, we really shouldn't expect any defined machine state.
The vm-host needs to be created before running tests: either by the test runner (Jenkins) or the tests themselves
When running integration tests the following error is observed:
[2024-01-17T10:07:28.063Z] 2024-01-17 10:07:14 INFO test_setup_ansible_collection: |fatal: [testhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 121, in <module>\n File \"<stdin>\", line 113, in _ansiballz_main\n File \"<stdin>\", line 61, in invoke_module\n File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_maas.maas.vm_host_payload_dbwfz2rh/ansible_maas.maas.vm_host_payload.zip/ansible_collections/maas/maas/plugins/modules/vm_host.py\", line 462, in <module>\n File \"/tmp/ansible_maas.maas.vm_host_payload_dbwfz2rh/ansible_maas.maas.vm_host_payload.zip/ansible_collections/maas/maas/plugins/modules/vm_host.py\", line 455, in main\n File \"/tmp/ansible_maas.maas.vm_host_payload_dbwfz2rh/ansible_maas.maas.vm_host_payload.zip/ansible_collections/maas/maas/plugins/modules/vm_host.py\", line 408, in run\n File \"/tmp/ansible_maas.maas.vm_host_payload_dbwfz2rh/ansible_maas.maas.vm_host_payload.zip/ansible_collections/maas/maas/plugins/modules/vm_host.py\", line 336, in deploy_machine_as_vm_host\n File \"/tmp/ansible_maas.maas.vm_host_payload_dbwfz2rh/ansible_maas.maas.vm_host_payload.zip/ansible_collections/maas/maas/plugins/modules/vm_host.py\", line 326, in data_for_deploy_machine_as_vm_host\nTypeError: 'NoneType' object is not subscriptable\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
The reason is that the default power_parameters
with default power_type
are not picked up. As such the params["power_type"]
is None
.
When deploying a machine, you have the option of registering the host as a VM host. This cannot be done via the collection as the deployment parameters for the instance module do not allow you to set this parameter currently.
When running the integration tests, there are initial steps such as the following:
- name: Delete machine
canonical.maas.machine: &delete-machine
fqdn: block-device-test.maas
state: absent
- name: Delete block device
canonical.maas.block_device: &delete-block-device
machine_fqdn: block-device-test.maas
name: my-block-device
state: absent
- name: Delete block device updated
canonical.maas.block_device: &delete-block-device-updated
machine_fqdn: block-device-test.maas
name: my-block-device-updated
state: absent
but instead of ok: [testhost]
on initial runs where the machine and block devices do not exist, it errors with the following:
fatal: [testhost]: FAILED! => {"changed": false, "msg": "No records from endpoint /api/2.0/machines/ match the {'fqdn': 'block-device-test.maas'} query."}
MAAS allow DHCP relay to forward DHCP requests to another VLAN that MAAS is managing.
Ansible Collection should support relay_vlan
parameter in module canonical.maas.vlan
(see PUT /MAAS/api/2.0/fabrics/{fabric_id}/vlans/{vid}/
in MAAS API reference).
The issue to implement a DHCP Snippets module.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.