当前位置: 动力学知识库 > 问答 > 编程问答 >

How to modify default ansible reachable test method

问题描述:

As we know, ansible connects remote machine by ssh, then ansible will run setup task, in this task, there is a step which will create a temp directory under $HOME/.ansible/tmp folder (default setting is under $HOME/.ansible/tmp, we could modify this in ansible.cfg file).

If failed to create the temp folder, ansible will report ansible authentication or permission failure, the remote host is unreachable.

However, I have a problem, my remote machine is accessed by serial console over LAN, it cannot create temp folder, can I modify the default reachable test method?

Or does anyone please give me suggestion how to manage remote host in ansible through serial console over LAN.

thanks.

网友答案:

If you need to prepare your remote box to be managed by Ansible, there are two ways:

1) raw module if the box in question is accessible via ssh and is able to execute arbitrary commands. This method is used, for example, to install Python2 on Ubuntu 16 images to allow Ansible execute setup and other modules.

2) Use commands/script from your control machine first. For example if you use raw tcp connection to get your serial console connection, you can do something like this:

- hosts: box
  gather_facts: no
  tasks:
    - expect:
        command: nc box 1234
        responses:
          login: user
          password: password
          user: /path/to/bootstrap_script.sh && exit
      delegate_to: localhost
    - setup:
    - other_ansible_module:
分享给朋友:
您可能感兴趣的文章:
随机阅读: