Hướng dẫn usr/bin/python not found - usr / bin / python không tìm thấy

Mục lục

  • Các giải pháp có sẵn
    • Tùy chọn 1 - Đặt
      $ which python
      
      $ python --version
      
      Command 'python' not found, but can be installed with:
      
      sudo apt install python3
      sudo apt install python
      sudo apt install python-minimal
      
      You also have python3 installed, you can run 'python3' instead.
      
      6 cho các máy chủ có
      $ which python
      
      $ python --version
      
      Command 'python' not found, but can be installed with:
      
      sudo apt install python3
      sudo apt install python
      sudo apt install python-minimal
      
      You also have python3 installed, you can run 'python3' instead.
      
      7 được cài đặt theo mặc định
    • Tùy chọn 2 - Cài đặt Python 2 trên máy chủ từ xa bằng cách sử dụng mô -đun Ansible từ
      $ which python
      
      $ python --version
      
      Command 'python' not found, but can be installed with:
      
      sudo apt install python3
      sudo apt install python
      sudo apt install python-minimal
      
      You also have python3 installed, you can run 'python3' instead.
      
      8
    • Tùy chọn 3 - Symlink
      $ which python
      
      $ python --version
      
      Command 'python' not found, but can be installed with:
      
      sudo apt install python3
      sudo apt install python
      sudo apt install python-minimal
      
      You also have python3 installed, you can run 'python3' instead.
      
      9 Sử dụng mô -đun Ansible từ
      $ which python
      
      $ python --version
      
      Command 'python' not found, but can be installed with:
      
      sudo apt install python3
      sudo apt install python
      sudo apt install python-minimal
      
      You also have python3 installed, you can run 'python3' instead.
      
      8
  • Kết luận và các khuyến nghị của tôi
  • đọc thêm

Show

Nếu bạn cố gắng chạy ansible chống lại một số trường hợp mới của Ubuntu 18.04, bạn rất có thể sẽ gặp phải một lỗi như thế này:

TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false, 
  "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", 
  "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
  "rc": 127

Điều này là do Ubuntu 18.04 không bao gồm

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1 (Python 2) theo mặc định. Bạn có thể xác nhận điều này cho chính mình bằng cách
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
2ing vào ví dụ và kiểm tra
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
3:

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.

Shell hữu ích chỉ ra rằng chúng tôi đã cài đặt

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
7 và có thể sử dụng nó thay thế. Lý do ansible của chúng tôi đã thất bại mặc dù
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
7 được cài đặt là do Ansible vẫn cố gắng sử dụng Python 2 (
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1) theo mặc định.

Các giải pháp có sẵn

Tùy chọn 1 - Đặt

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
6 cho các máy chủ có
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
7 được cài đặt theo mặc định

  1. Tùy chọn 2 - Cài đặt Python 2 trên máy chủ từ xa bằng cách sử dụng mô -đun Ansible từ
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    8
  2. Tùy chọn 3 - Symlink
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    9 Sử dụng mô -đun Ansible từ
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    8
  3. Kết luận và các khuyến nghị của tôi

đọc thêm

Tùy chọn 1 - Đặt $ which python $ python --version Command 'python' not found, but can be installed with: sudo apt install python3 sudo apt install python sudo apt install python-minimal You also have python3 installed, you can run 'python3' instead. 6 cho các máy chủ có $ which python $ python --version Command 'python' not found, but can be installed with: sudo apt install python3 sudo apt install python sudo apt install python-minimal You also have python3 installed, you can run 'python3' instead. 7 được cài đặt theo mặc định

Tùy chọn 2 - Cài đặt Python 2 trên máy chủ từ xa bằng cách sử dụng mô -đun Ansible từ

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

Tùy chọn 3 - Symlink

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
9 Sử dụng mô -đun Ansible từ
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host

Kết luận và các khuyến nghị của tôi

PLAY [misc task on ubuntu 18.04 instance]

TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false, 
  "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", 
  "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
  "rc": 127

đọc thêm

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  vars:
    ansible_python_interpreter: /usr/bin/python3
  tasks:
    - debug: var=ansible_host

Nếu bạn cố gắng chạy ansible chống lại một số trường hợp mới của Ubuntu 18.04, bạn rất có thể sẽ gặp phải một lỗi như thế này:

PLAY [misc task on ubuntu 18.04 instance]

TASK [Gathering Facts]
ok: [123.123.123.123]

TASK [debug]
ok: [123.123.123.123] => {
    "ansible_host": "123.123.123.123"
}

Điều này là do Ubuntu 18.04 không bao gồm

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1 (Python 2) theo mặc định. Bạn có thể xác nhận điều này cho chính mình bằng cách
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
2ing vào ví dụ và kiểm tra
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
3:

  • Shell hữu ích chỉ ra rằng chúng tôi đã cài đặt
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    7 và có thể sử dụng nó thay thế. Lý do ansible của chúng tôi đã thất bại mặc dù
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    7 được cài đặt là do Ansible vẫn cố gắng sử dụng Python 2 (
    - name: misc task on ubuntu 18.04 instance
      hosts: "*"
      tasks:
        - debug: var=ansible_host
    
    1) theo mặc định.all your remote hosts definitely have
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    7, you can just add the variable to your
    - name: misc task on ubuntu 18.04 instance
      hosts: "*"
      vars:
        ansible_python_interpreter: /usr/bin/python3
      tasks:
        - debug: var=ansible_host
    
    0 file:

# group_vars/all.yml

ansible_python_interpreter: /usr/bin/python3

  • Có 3 cách để giải quyết vấn đề này nếu bạn gặp phải nó trên máy chủ từ xa của mình:

# group_vars/tag_OS_ubuntu1804.yml

ansible_python_interpreter: /usr/bin/python3

  • Đặt biến
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    6 cho tất cả các máy chủ có
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    7 được cài đặt theo mặc định

[python2_hosts]
centos7_server

[python3_hosts]
u1804_server

[python3_hosts:vars]
ansible_python_interpreter=/usr/bin/python3

Cài đặt Python 2 bằng mô -đun Ansible từ

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

Symlink

PLAY [misc task on ubuntu 18.04 instance]

TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false, 
  "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", 
  "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
  "rc": 127
0 đến
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1 bằng cách sử dụng mô -đun Ansible từ
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

Tất cả 3 tùy chọn có thể được thực hiện trong ansible, mà không cần

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
2ing vào máy chủ, đây là tin tốt cho chúng tôi (và tự động hóa). Trong các phần sau, tôi sẽ chỉ ra cách bạn có thể sử dụng từng tùy chọn và ưu/nhược điểm của từng tùy chọn.

Đây là tùy chọn được đưa ra trong các tài liệu Ansible chính thức về hỗ trợ Python 3. Các tài liệu đề nghị đặt

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
6 cho các máy chủ từ xa đã cài đặt Python 3. Hãy để thử nghiệm nó ra?

Hãy xem kết quả của việc chạy vở kịch sau đối với một phiên bản mới của Ubuntu 18.04:

Tùy chọn 2 - Cài đặt Python 2 trên máy chủ từ xa bằng cách sử dụng mô -đun Ansible từ $ which python $ python --version Command 'python' not found, but can be installed with: sudo apt install python3 sudo apt install python sudo apt install python-minimal You also have python3 installed, you can run 'python3' instead. 8

Tùy chọn 3 - Symlink

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
9 Sử dụng mô -đun Ansible từ
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

Kết luận và các khuyến nghị của tôi

đọc thêm

Nếu bạn cố gắng chạy ansible chống lại một số trường hợp mới của Ubuntu 18.04, bạn rất có thể sẽ gặp phải một lỗi như thế này:

sudo apt-get update
sudo apt-get -y install python

Điều này là do Ubuntu 18.04 không bao gồm

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1 (Python 2) theo mặc định. Bạn có thể xác nhận điều này cho chính mình bằng cách
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
2ing vào ví dụ và kiểm tra
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
3:

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
0

Shell hữu ích chỉ ra rằng chúng tôi đã cài đặt

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
7 và có thể sử dụng nó thay thế. Lý do ansible của chúng tôi đã thất bại mặc dù
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
7 được cài đặt là do Ansible vẫn cố gắng sử dụng Python 2 (
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1) theo mặc định.

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
1

Có 3 cách để giải quyết vấn đề này nếu bạn gặp phải nó trên máy chủ từ xa của mình:

Cài đặt Python 2 bằng mô -đun Ansible từ

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

Symlink

PLAY [misc task on ubuntu 18.04 instance]

TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false, 
  "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", 
  "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
  "rc": 127
0 đến
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1 bằng cách sử dụng mô -đun Ansible từ
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
2

Tất cả 3 tùy chọn có thể được thực hiện trong ansible, mà không cần

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
2ing vào máy chủ, đây là tin tốt cho chúng tôi (và tự động hóa). Trong các phần sau, tôi sẽ chỉ ra cách bạn có thể sử dụng từng tùy chọn và ưu/nhược điểm của từng tùy chọn.

Đây là tùy chọn được đưa ra trong các tài liệu Ansible chính thức về hỗ trợ Python 3. Các tài liệu đề nghị đặt

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
6 cho các máy chủ từ xa đã cài đặt Python 3. Hãy để thử nghiệm nó ra?to the top of every playbook (or
# group_vars/all.yml

ansible_python_interpreter: /usr/bin/python3

2 it). This is a lot of needless repetition and adds a potential source of failure if we haven’t done it.

Hãy xem kết quả của việc chạy vở kịch sau đối với một phiên bản mới của Ubuntu 18.04:

Một tùy chọn khác trong một tĩnh mạch tương tự với tùy chọn 2 là sử dụng mô -đun

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
8 để đối với SymLink, ____ ____.

Với một chút phép thuật shell, chúng ta có thể tạo ra một lệnh để thực hiện điều này một cách có điều kiện dựa trên việc liệu một trong hai tệp tồn tại bằng cách sử dụng các điều kiện:

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
3

Lệnh này nói:

Nếu

PLAY [misc task on ubuntu 18.04 instance]

TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false, 
  "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", 
  "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
  "rc": 127
0 tồn tại và
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
1 không tồn tại thì hãy tạo một liên kết tượng trưng
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
9.does not exist then create a symbolic link
$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
9.

Điều này làm cho lệnh đủ linh hoạt để chạy trên tất cả các hệ thống mà không cần bất kỳ

# group_vars/all.yml

ansible_python_interpreter: /usr/bin/python3

1 nào. Ví dụ, trên hệ thống Centos 7, điều kiện sẽ đánh giá thành
# group_vars/tag_OS_ubuntu1804.yml

ansible_python_interpreter: /usr/bin/python3
1 vì
PLAY [misc task on ubuntu 18.04 instance]

TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false, 
  "module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n", 
  "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
  "rc": 127
0 không tồn tại.

Ở dạng ansible:

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
4

Bạn sẽ thấy đầu ra sau:

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
5

Ưu điểm

So với tùy chọn 2, phương pháp này nhanh hơn đáng kể và không yêu cầu chúng tôi bỏ qua các lỗi. Ngoài ra, bằng cách sử dụng một câu lệnh có điều kiện có nghĩa là chúng ta chỉ tạo liên kết symlink nếu

$ which python

$ python --version

Command 'python' not found, but can be installed with:

sudo apt install python3
sudo apt install python
sudo apt install python-minimal

You also have python3 installed, you can run 'python3' instead.
7 tồn tại và
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  tasks:
    - debug: var=ansible_host
3 không có, mà: mà:

  • Ngăn chặn lỗi trong trường hợp
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    7 không tồn tại
  • ngăn chúng tôi ghi đè
    - name: misc task on ubuntu 18.04 instance
      hosts: "*"
      tasks:
        - debug: var=ansible_host
    
    3 nếu nó đã được cài đặt

Nhược điểm

Nhược điểm thực sự duy nhất của phương pháp này là - như tùy chọn 2 - chúng ta cần thêm hoặc

# group_vars/all.yml

ansible_python_interpreter: /usr/bin/python3

2 vở kịch này ở đầu tất cả các playbook của chúng tôi, điều này thêm sự trùng lặp không cần thiết và có thể là một nguồn lỗi.all our playbooks, which adds unnecessary duplication and may be a source of errors.

Kết luận và các khuyến nghị của tôi

Đây là một điều thực sự khó gọi. Mỗi tùy chọn có ưu điểm và nhược điểm và giải pháp tôi khuyên bạn nên thực sự phụ thuộc vào tình huống của bạn.

Đối với tôi, tùy chọn 1 nói chung là vượt trội vì nó không yêu cầu thay đổi playbook của bạn và không yêu cầu thay đổi máy chủ từ xa theo bất kỳ cách nào.option 1 is generally superior because it doesn’t require changing your playbooks and doesn’t require changing the remote host in any way.

Tôi nghĩ Tùy chọn 1 là giải pháp tốt nhất nếu tất cả các máy chủ từ xa của bạn đang chạy phân phối với Python 3 được cài đặt theo mặc định (ví dụ: Ubuntu 16.04 trở lên). Nó cũng là giải pháp tốt nhất nếu bạn đã gắn thẻ cơ sở hạ tầng của mình với phiên bản HĐH và HĐH (ví dụ: thẻ AWS) hoặc nếu bạn sử dụng cơ sở hạ tầng tĩnh và bạn đã nhóm các máy chủ của mình theo hệ điều hành.option 1 is the best solution if all your remote hosts are running a distro with Python 3 installed by default (e.g. Ubuntu 16.04 and up). It’s also the best solution if you’ve already tagged your infrastructure with the OS and OS version (e.g. AWS tags), or if you’re using static infrastructure and you’ve already grouped your servers by OS.

Tôi nghĩ tùy chọn 3 là giải pháp tốt nhất nếu bạn đang xử lý các máy chủ từ xa có thể không cài đặt Python 3 theo mặc định hoặc không có cách nào dễ dàng để áp dụng

- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  vars:
    ansible_python_interpreter: /usr/bin/python3
  tasks:
    - debug: var=ansible_host
4 dựa trên HĐH. Lý do tùy chọn này chiến thắng tùy chọn 2 là vì nó nhanh hơn đáng kể và có thể chạy chống lại bất kỳ sự phân phối nào mà không cần xử lý lỗi đặc biệt.option 3 is the best solution if you are dealing with remote hosts that may not have Python 3 installed by default, or have no easy way to apply
- name: misc task on ubuntu 18.04 instance
  hosts: "*"
  vars:
    ansible_python_interpreter: /usr/bin/python3
  tasks:
    - debug: var=ansible_host
4 based on the OS. The reason this option wins out over option 2 is because it’s significantly faster and can run against any distro without any special error handling.

Biết về bất kỳ cách nào khác để giải quyết vấn đề này? Hãy bình luận bên dưới và cho tôi biết bạn nghĩ gì!

đọc thêm

  • Python 3 Hỗ trợ về tài liệu Ansible
  • Mô -đun ANSible
    $ which python
    
    $ python --version
    
    Command 'python' not found, but can be installed with:
    
    sudo apt install python3
    sudo apt install python
    sudo apt install python-minimal
    
    You also have python3 installed, you can run 'python3' instead.
    
    8 trên tài liệu Ansible
  • Mô -đun ANSible
    PLAY [misc task on ubuntu 18.04 instance]
    
    TASK [Gathering Facts]
    ok: [123.123.123.123]
    
    TASK [debug]
    ok: [123.123.123.123] => {
        "ansible_host": "123.123.123.123"
    }
    
    3 trên tài liệu Ansible
  • Xử lý lỗi trong Playbooks trên tài liệu Ansible

Nhận xét & Chia sẻ