使用Ansible通过SSH隧道配置F5

时间:2017-08-09 23:49:05

标签: python ansible ssh-tunnel f5

我目前在通过SSH Bastion主机运行Ansible F5手册时遇到问题,无法确定在此阶段可能出现问题的地方。

BIGSUDS,SUDS,F5-SDK全部通过pip安装

我的手册 --- f5play.yml ----

---
- hosts: f5_devices
  gather_facts: false
  connection: local

  tasks:
  - name: f5 test
    bigip_facts:
      server: "{{ inventory_hostname }}"
      user: "{{ ansible_user }}"
      password: "{{ ansible_ssh_pass }}"
      include: "interface"
      validate_certs: false
    delegate_to: localhost
    register: out

  - debug: msg= "{{ out }}"

我有一个" group_vars"带有" f5_devices"的目录包含我的vault.yml和vars.yml

的目录

vars.yml包含我的额外代理信息,在跳转到f5之前跳过中间ssh主机,它已成功用于此设置,然后才能访问Cisco设备。

库存文件= ansible_hosts

[f5_devices]
F5-LTM1  ansible_user=admin

- vars.yml -

ansible_ssh_pass: "{{ vault_ansible_ssh_pass }}"
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -v bastion1" -o 
StrictHostKeyChecking=no'

ansible-playbook -i ansible_hosts f5play.yml --ask-vault-pass -vvv

更新 - 添加" delegate_to:localhost" 现在,仍然是这个错误

            "session": false,
            "state": "present",
            "user": "admin",
            "validate_certs": false
        }
    },
    "msg": "received exception: <urlopen error [Errno -2] Name or service 
not known>\ntraceback: Traceback (most recent call last):\n  File 
\"/tmp/ansible_cdaERk/ansible_module_bigip_facts.py\", line 1664, in main\n    
saved_active_folder = f5.get_active_folder()\n  File 
\"/tmp/ansible_cdaERk/ansible_module_bigip_facts.py\", line 148, in 
get_active_folder\n    return self.api.System.Session.get_active_folder()\n  
File \"/home/mike/Proj/ansible/lib/python2.7/site-packages/bigsuds.py\", 
line 360, in __getattr__\n    client = self._client_creator('%s.%s' % 
(self._name, attr))\n  File \"/home/mike/Proj/ansible/lib/python2.7/site-
packages/bigsuds.py\", line 170, in _create_client\n    raise 
ConnectionError(str(e))\nConnectionError: <urlopen error [Errno -2] Name or 
service not known>\n"
}

我忘了添加,这是在虚拟环境中运行(virtualenv ansible)

任何帮助都会非常重要。理解

1 个答案:

答案 0 :(得分:0)

我猜,你应该:

  • 删除connection: local
  • 删除f5_devices群组
  • 的ssh和代理设置
  • bastion1主机添加到您的广告资源
  • 然后delegate_to: bastion1

这样Ansible将连接到您的堡垒主机,并从那里以f5设备为目标执行bigip_facts模块。