rundeck-plugins / ansible-plugin

Ansible Integration for Rundeck
MIT License
330 stars 100 forks source link

Modules and Python Interpreter Discovery in venv #309

Open holynakamoto opened 2 years ago

holynakamoto commented 2 years ago

Did a build and release on PR 288

Inventory is populating however when running jobs I seem to be having an issue with python interpreter discovery.

Also when I try to reference collections and modules I am running into an issue with discovery.

The interpreter is specified in the ansible.cfg

(ansible-prd) nmoore@itnet-bastion0:~/neteng/automation/ansible$ ansible --version
ansible [core 2.12.0]
  config file = **/home/nmoore/neteng/automation/ansible/ansible.cfg**
  configured module search path = ['/home/nmoore/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/nmoore/anaconda3/envs/ansible-prd/lib/python3.8/site-packages/ansible
  ansible collection location = /home/nmoore/.ansible/collections
  executable location = /home/nmoore/anaconda3/envs/ansible-prd/bin/ansible
  python version = 3.8.8 (default, Apr 13 2021, 19:58:26) [GCC 7.3.0]
  jinja version = 2.11.3
  libyaml = True
(ansible-prd) nmoore@itnet-bastion0:~/neteng/automation/ansible$ cat /home/nmoore/neteng/automation/ansible/ansible.cfg
[defaults]
inventory = /home/nmoore/neteng/automation/ansible/inventory/inventory.yaml
deprecation_warnings = False
remote_port = 22
host_key_checking = False
roles_path = ~/.ansible/roles
collections_path = ~/.ansible/collections
stdout_callback = yaml
**ansible_python_interpreter = /home/nmoore/anaconda3/envs/ansible-prd/bin/python**
ansible_ssh_user = bastion
ansible_network_os = junipernetworks.junos.junos
[persistent_connection]
connect_timeout = 600
[inventory]
enable_plugins = yaml, ini
[ssh_connection]
scp_if_ssh=True

Basic Ping Test using standard ping module

---
- hosts: junos_all
  tasks:
    - name: test connection
      ping:
PLAY [junos_all] ***************************************************************
TASK [Gathering Facts] *********************************************************
[WARNING]: Unhandled error in Python interpreter discovery for host
ams1-cgw1.corp.****.com: unexpected output from Python interpreter
discovery
fatal: [ams1-cgw1.corp.****.com]: FAILED! =>
msg: |-
failed to transfer file to /var/lib/rundeck/.ansible/tmp/ansible-local-114011oijljg5/tmpz7k8bdsf error: unknown command: **/bin/sh/AnsiballZ_setup.py:**
scp: error: unknown command: /bin/sh/AnsiballZ_setup.py: No such file or directory
PLAY RECAP *********************************************************************
ams1-cgw1.corp.****.com : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0  

Testing w/ Roles/Collections

(ansible-prd) nmoore@itnet-bastion0:~/neteng/automation/ansible$ cat junos_pull_config_pb.yaml
---
- name: Junos Config Dump
  hosts: junos_all
  connection: local
  gather_facts: false
  roles:
    - junos_pull_config
(ansible-prd) nmoore@itnet-bastion0:~/neteng/automation/ansible$ cat roles/junos_pull_config/tasks/main.yaml
---
- name: "Get committed configuration"
  juniper.device.config:
    timeout: 120
    retrieve: "committed"
    format: "set"
    dest_dir: "{{ playbook_dir }}/roles/junos_pull_config/files/configs/set"
  register: response
ERROR! couldn't resolve module/action 'juniper.device.config'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/home/nmoore/neteng/automation/ansible/roles/junos_pull_config/tasks/main.yaml': line 8, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
#  register: response
- name: "Get committed configuration"
  ^ here
Failed: AnsibleNonZero: ERROR: Ansible execution returned with non zero code.
(ansible-prd) nmoore@itnet-bastion0:~/neteng/automation/ansible$ ansible-galaxy collection list | grep device
juniper.device         1.0.1

Project Settings:

#Thu Mar 03 17:43:02 UTC 2022
#edit below
ansible-binaries-dir-path=/home/nmoore/anaconda3/envs/ansible-prd/bin/
project.ansible-binaries-dir-path=/home/nmoore/anaconda3/envs/ansible-prd/bin/
project.ansible-config-file-path=/home/nmoore/neteng/automation/ansible/ansible.cfg
**project.ansible-executable=/bin/bash**
project.ansible-generate-inventory=true
project.ansible-ssh-auth-type=privateKey
project.ansible-ssh-key-storage-path=keys/project/Self_Service_Portal/nmoorepriv
project.ansible-ssh-passphrase-option=option.password
project.ansible-ssh-user=nmoore
project.description=
project.disable.executions=false
project.disable.schedule=false
project.execution.history.cleanup.batch=500
project.execution.history.cleanup.enabled=false
project.execution.history.cleanup.retention.days=60
project.execution.history.cleanup.retention.minimum=50
project.execution.history.cleanup.schedule=0 0 0 1/1 * ? *
project.jobs.gui.groupExpandLevel=1
project.label=
[project.name](http://project.name/)=Self_Service_Portal
project.nodeCache.enabled=true
project.nodeCache.firstLoadSynch=true
project.output.allowUnsanitized=false
project.ssh-authentication=privateKey
project.ssh-keypath=/var/lib/rundeck/.ssh/id_rsa
resources.source.1.config.ansible-config-file-path=/home/nmoore/neteng/automation/ansible/ansible.cfg
resources.source.1.config.ansible-gather-facts=false
resources.source.1.config.ansible-ignore-errors=true
resources.source.1.config.ansible-inventory=/home/nmoore/neteng/automation/ansible/inventory/inventory.yaml
resources.source.1.config.ansible-ssh-auth-type=password
resources.source.1.config.ansible-ssh-password=*****
resources.source.1.config.ansible-ssh-user=nmoore
resources.source.1.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
service.FileCopier.default.provider=jsch-scp
service.NodeExecutor.default.provider=com.batix.rundeck.plugins.AnsibleNodeExecutor
holynakamoto commented 2 years ago
Screen Shot 2022-03-14 at 11 10 20 AM
elioe commented 2 years ago

Santander Customer is facing this same issue and they already know since this was a Public Repo (Batix) there is a potential solution in the PR 288

This is a blocker for the customer. SF ticket No. 00083945