diff --git a/roles/inventory/linode/tasks/main.yml b/roles/inventory/linode/tasks/main.yml index fae629c..9f30d08 100644 --- a/roles/inventory/linode/tasks/main.yml +++ b/roles/inventory/linode/tasks/main.yml @@ -1,12 +1,19 @@ --- # Main tasks for linode_inventory role +- name: Set API token (AWX credential injection takes precedence) + ansible.builtin.set_fact: + linode_api_token: "{{ linode_api_token | default(lookup('env', 'LINODE_API_TOKEN')) | default('') }}" + - name: Validate required variables ansible.builtin.assert: that: - linode_api_token is defined - linode_api_token | length > 0 - fail_msg: "linode_api_token must be defined and not empty" + fail_msg: | + Linode API token not found. + For AWX: Attach a Linode API Token credential to your job template + For local: Set LINODE_API_TOKEN environment variable or pass linode_api_token variable quiet: true - name: Ensure output directory exists @@ -16,20 +23,6 @@ mode: '0755' delegate_to: localhost -- name: Check if Python requests module is available - ansible.builtin.command: python3 -c "import requests" - register: python_requests_check - failed_when: false - changed_when: false - delegate_to: localhost - -- name: Install Python requests if not available - ansible.builtin.pip: - name: requests - state: present - when: python_requests_check.rc != 0 - delegate_to: localhost - - name: Copy Linode inventory script ansible.builtin.copy: src: linode_inventory.py