Several changes here

This commit is contained in:
2025-08-07 14:00:17 -05:00
parent c5851bd287
commit 7a99ea3167
3 changed files with 166 additions and 14 deletions

View File

@@ -11,6 +11,15 @@
awx_integration: true
cleanup_temp_files: false
# Git integration settings
push_to_git: true
# AWX API integration (optional - for automatic project sync)
awx_api_integration: false # Set to true if you want automatic project refresh
# awx_host: "https://your-awx-host"
# awx_project_id: "8" # Your project ID in AWX
# awx_token: "{{ lookup('env', 'AWX_TOKEN') }}" # Set via credential or env var
# Optional filters
include_only_running: false
specific_regions: [] # e.g., ['us-east', 'us-west']
@@ -42,17 +51,24 @@
msg: |
Inventory update complete!
Next steps for AWX integration:
1. Copy the inventory script to your SCM repository
2. Create a custom inventory source in AWX
3. Point it to the linode_inventory.py script
4. Set up the Linode API credential
✅ Inventory file created: /runner/project/inventory/linode_hosts.json
✅ Changes committed to Git: {{ 'Yes' if git_commit_result.rc == 0 else 'Failed - check logs' }}
✅ Repository: git@git.ewnix.net:phlux/ewnix-automation.git
Files created:
- JSON inventory: {{ linode_inventory_output_dir }}/{{ linode_inventory_output_file }}
{% if inventory_format == "ini" %}
- INI inventory: {{ linode_inventory_output_dir }}/linode_static_inventory.ini
{% endif %}
Next steps:
1. {% if not awx_api_integration %}Manually sync your AWX project to pull the latest inventory{% else %}Project sync triggered automatically{% endif %}
2. Create a new inventory source in AWX:
- Source: "Sourced from a Project"
- Inventory File: "inventory/linode_hosts.json"
- No credential needed (it's a static file)
3. Sync the inventory source to import your Linode hosts
Your {{ linode_inventory_data._meta.hostvars | length }} Linode hosts will be available in groups:
- tag_k3s (k3s cluster nodes)
- tag_control_plane ({{ hostvars[groups['localhost'][0]]['linode_inventory_data']._meta.hostvars | selectattr('is_control_plane', 'equalto', true) | list | length }} control plane nodes)
- tag_worker_node ({{ hostvars[groups['localhost'][0]]['linode_inventory_data']._meta.hostvars | selectattr('is_worker_node', 'equalto', true) | list | length }} worker nodes)
- region_us_southeast (regional grouping)
- type_* (by instance type)
# Optional: Run against discovered Linode hosts
- name: Debug and use discovered Linode hosts

View File

@@ -0,0 +1,54 @@
---
# Example workflow that updates inventory and then uses it
- name: Step 1 - Update Linode Inventory
hosts: localhost
gather_facts: true
connection: local
vars:
push_to_git: true
awx_api_integration: true
awx_host: "{{ lookup('env', 'TOWER_HOST') | default('https://localhost') }}"
awx_project_id: "{{ lookup('env', 'AWX_PROJECT_ID') | default('') }}"
awx_token: "{{ lookup('env', 'AWX_TOKEN') | default('') }}"
roles:
- role: linode_inventory
- name: Step 2 - Wait for project sync (if using API)
hosts: localhost
gather_facts: false
tasks:
- name: Wait for project sync to complete
ansible.builtin.pause:
seconds: 30
when: awx_api_integration | default(false)
- name: Manual sync reminder
ansible.builtin.debug:
msg: |
⚠️ MANUAL ACTION REQUIRED ⚠️
Please manually sync your AWX project now to pull the updated inventory file.
Then create/sync an inventory source pointing to: inventory/linode_hosts.json
After that, you can run jobs against your discovered Linode hosts!
when: not (awx_api_integration | default(false))
# This play would run in a separate job template after inventory is synced
- name: Step 3 - Example task using discovered hosts
hosts: localhost
gather_facts: false
tasks:
- name: Instructions for next job template
ansible.builtin.debug:
msg: |
This would be a separate job template that runs after inventory sync.
It would target groups like:
- tag_k3s
- tag_control_plane
- tag_worker_node
- region_us_southeast
Example: Create a job template with inventory pointing to the Linode hosts
and limit it to specific groups like 'tag_k3s' to run tasks on k3s nodes only.