Cum se instalează Ansible pe MacOS folosind Homebrew sau Python pip?
Publicat: 2019-02-24
Ansible este unul dintre cele mai puternice instrumente de automatizare IT existente. Se completează direct cu SaltStack
, Docker și așa mai departe. În acest tutorial vom trece peste pașii despre cum să instalați Ansible pe macOS?
- Configurare și configurare Mac prin Ansible.
- Cum se instalează Ansible pe Apple MacOS X folosind linia de comandă?
- instalați ansible pe macOS Mojave
Să începem.
Există două moduri prin care putem instala Ansible.
- Opțiunea 1. Folosind Homebrew.
- Homebrew este un sistem de gestionare a pachetelor software gratuit și open-source care simplifică instalarea software-ului pe sistemul de operare Apple
- Opțiunea-2: Folosind comanda pip.
- Managerul de pachete standard pentru Python este pip.
Opțiunea 1. Folosind Homebrew

Pasul 1.
- Asigurați-vă că instalați mai întâi homebrew pe MacOS.
Pasul 2.
- Comanda pentru a instala Ansible.
1 |
bash - 3.2 $ brew install ansible |
Iată un jurnal:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
bash - 3.2 $ brew install ansible Running ` brew update -- preinstall ` . . . == > Auto - updated Homebrew ! Updated 1 tap ( homebrew / core ) . == > New Formulae asyncapi esphome ffmpeg @ 4 linode - cli rure usbutils == > Updated Formulae Updated 225 formulae . == > Downloading https : //ghcr.io/v2/homebrew/core/ansible/manifests/5.2.0 ######################################################################## 100.0% == > Downloading https : //ghcr.io/v2/homebrew/core/ansible/blobs/sha256:ed415688614ad6a8fc68aa9e886c9296053cfca375aa70759ee5dc5e56da43f1 == > Downloading from https : //pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ed415688614ad6a8fc68aa9e886c9296053cfca375aa70759ee5dc5e56da43f1?se=202 ######################################################################## 100.0% == > Installing dependencies for ansible : libyaml , gdbm , mpdecimal , xz , python @ 3.10 and six == > Installing ansible dependency : libyaml == > Pouring libyaml -- 0.2.5.monterey.bottle.tar.gz / usr / local / Cellar / libyaml / 0.2.5 : 10 files , 331.3KB == > Installing ansible dependency : gdbm == > Pouring gdbm -- 1.22.monterey.bottle.tar.gz / usr / local / Cellar / gdbm / 1.22 : 24 files , 941.7KB == > Installing ansible dependency : mpdecimal == > Pouring mpdecimal -- 2.5.1.monterey.bottle.tar.gz / usr / local / Cellar / mpdecimal / 2.5.1 : 71 files , 2.1MB == > Installing ansible dependency : xz == > Pouring xz -- 5.2.5.monterey.bottle.tar.gz / usr / local / Cellar / xz / 5.2.5 : 95 files , 1.3MB == > Installing ansible dependency : python @ 3.10 == > Pouring python @ 3.10 -- 3.10.2.monterey.bottle.tar.gz == > / usr / local / Cellar / python @ 3.10 / 3.10.2 / bin / python3 - m ensurepip == > / usr / local / Cellar / python @ 3.10 / 3.10.2 / bin / python3 - m pip install - v -- no - deps -- no - index -- upgrade -- isolated -- target =/ usr / local / lib / python3 . 10 / site - pac / usr / local / Cellar / python @ 3.10 / 3.10.2 : 3 , 133 files , 56.4MB == > Installing ansible dependency : six == > Pouring six -- 1.16.0_2.all.bottle.1.tar.gz / usr / local / Cellar / six / 1.16.0_2 : 20 files , 122.3KB == > Installing ansible == > Pouring ansible -- 5.2.0.monterey.bottle.tar.gz Error : The ` brew link ` step did not complete successfully The formula built , but is not symlinked into / usr / local Could not symlink bin / ansible Target / usr / local / bin / ansible already exists . You may want to remove it : rm '/usr/local/bin/ansible' To force the link and overwrite all conflicting files : brew link -- overwrite ansible To list all files that would be deleted : brew link -- overwrite -- dry - run ansible Possible conflicting files are : / usr / local / bin / ansible / usr / local / bin / ansible - config / usr / local / bin / ansible - connection / usr / local / bin / ansible - console / usr / local / bin / ansible - doc / usr / local / bin / ansible - galaxy / usr / local / bin / ansible - inventory / usr / local / bin / ansible - playbook / usr / local / bin / ansible - pull / usr / local / bin / ansible - test / usr / local / bin / ansible - vault == > Summary / usr / local / Cellar / ansible / 5.2.0 : 44 , 382 files , 427.8MB == > Running ` brew cleanup ansible ` . . . Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP . Hide these hints with HOMEBREW_NO_ENV_HINTS ( see ` man brew ` ) . bash - 3.2 $ brew link -- overwrite ansible Linking / usr / local / Cellar / ansible / 5.2.0... 20 symlinks created . bash - 3.2 $ |
Pasul 3. Verificați versiunea Ansible
1 2 3 4 5 6 7 8 9 10 |
bash - 3.2 $ ansible -- version ansible [ core 2.12.1 ] config file = None configured module search path = [ '/Users/app/.ansible/plugins/modules' , '/usr/share/ansible/plugins/modules' ] ansible python module location = / usr / local / Cellar / ansible / 5.2.0 / libexec / lib / python3 . 10 / site - packages / ansible ansible collection location = / Users / app / . ansible / collections : / usr / share / ansible / collections executable location = / usr / local / bin / ansible python version = 3.10.2 ( main , Feb 2 2022 , 06 : 19 : 27 ) [ Clang 13.0.0 ( clang - 1300.0.29.3 ) ] jinja version = 3.0.3 libyaml = True |
Opțiunea-2. Folosind comanda pip
Pasul 1.
Instalați Ansible folosind comanda pip. PIP este un package manager
de pachete pentru pachetele Python. macOS nu are pip instalat în mod implicit. Mai întâi trebuie să-l instalați.
- Comanda:
sudo easy_install pip
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
bash - 3.2 $ sudo easy_install pip Password : Searching for pip Reading https : //pypi.python.org/simple/pip/ Best match : pip 19.0.3 Downloading https : //files.pythonhosted.org/packages/36/fa/51ca4d57392e2f69397cd6e5af23da2a8d37884a605f9e3f2d3bfdc48397/pip-19.0.3.tar.gz#sha256=6e6f197a1abfb45118dbb878b5c859a0edbdd33fd250100bc015b67fded4b9f2 Processing pip - 19.0.3.tar.gz Writing / tmp / easy_install - eYeYXb / pip - 19.0.3 / setup . cfg Running pip - 19.0.3 / setup . py - q bdist_egg -- dist - dir / tmp / easy_install - eYeYXb / pip - 19.0.3 / egg - dist - tmp - GvhMn8 / System / Library / Frameworks / Python . framework / Versions / 2.7 / lib / python2 . 7 / distutils / dist . py : 267 : UserWarning : Unknown distribution option : 'python_requires' warnings . warn ( msg ) warning : no files found matching 'docs/docutils.conf' warning : no previously - included files found matching '.coveragerc' warning : no previously - included files found matching '.mailmap' warning : no previously - included files found matching '.appveyor.yml' warning : no previously - included files found matching '.travis.yml' warning : no previously - included files found matching 'tox.ini' warning : no files found matching 'Makefile' under directory 'docs' warning : no files found matching '*.bat' under directory 'docs' warning : no previously - included files found matching 'src/pip/_vendor/six' warning : no previously - included files found matching 'src/pip/_vendor/six/moves' warning : no previously - included files matching '*.pyi' found under directory 'src/pip/_vendor' no previously - included directories found matching '.github' no previously - included directories found matching '.azure-pipelines' no previously - included directories found matching 'docs/build' no previously - included directories found matching 'news' no previously - included directories found matching 'tasks' no previously - included directories found matching 'tests' no previously - included directories found matching 'tools' creating / Library / Python / 2.7 / site - packages / pip - 19.0.3 - py2 . 7.egg Extracting pip - 19.0.3 - py2 . 7.egg to / Library / Python / 2.7 / site - packages Adding pip 19.0.3 to easy - install . pth file Installing pip script to / usr / local / bin Installing pip2 . 7 script to / usr / local / bin Installing pip2 script to / usr / local / bin Installed / Library / Python / 2.7 / site - packages / pip - 19.0.3 - py2 . 7.egg Processing dependencies for pip Finished processing dependencies for pip |
Pasul 2.
Utilizați pip pentru a instala Ansible.

- Comanda:
sudo pip install ansible
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
bash - 3.2 $ sudo pip install ansible DEPRECATION : Python 2.7 will reach the end of its life on January 1st , 2020. Please upgrade your Python as Python 2.7 won 't be maintained after that date. A future version of pip will drop support for Python 2.7. The directory ' / Users / ashah / Library / Caches / pip / http ' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo' s - H flag . The directory '/Users/ashah/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled . check the permissions and owner of that directory . If executing pip with sudo , you may want sudo ' s - H flag . Collecting ansible Downloading https : //files.pythonhosted.org/packages/e4/22/4325212e609071cd93b8142722d770f5defab34a95511f183e262f8de983/ansible-2.7.8.tar.gz (11.8MB) 100 % | -------------------------------- | 11.8MB 3.3MB / s Collecting jinja2 ( from ansible ) Downloading https : //files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB) 100 % | -------------------------------- | 133kB 10.4MB / s Collecting PyYAML ( from ansible ) Downloading https : //files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB) 100 % | -------------------------------- | 276kB 12.2MB / s Collecting paramiko ( from ansible ) Downloading https : //files.pythonhosted.org/packages/cf/ae/94e70d49044ccc234bfdba20114fa947d7ba6eb68a2e452d89b920e62227/paramiko-2.4.2-py2.py3-none-any.whl (193kB) 100 % | -------------------------------- | 194kB 7.0MB / s Collecting cryptography ( from ansible ) Downloading https : //files.pythonhosted.org/packages/f3/d0/f8bdea567805d96cfb42bd8289408df7a6687693fed658a950a90d14c49b/cryptography-2.5-cp27-cp27m-macosx_10_6_intel.whl (1.7MB) 100 % | -------------------------------- | 1.7MB 6.7MB / s Requirement already satisfied : setuptools in / System / Library / Frameworks / Python . framework / Versions / 2.7 / Extras / lib / python ( from ansible ) ( 18.5 ) Collecting MarkupSafe > = 0.23 ( from jinja2 - > ansible ) Downloading https : //files.pythonhosted.org/packages/cd/52/927263d9cf66a12e05c5caef43ee203bd92355e9a321552d2b8c4aee5f1e/MarkupSafe-1.1.0-cp27-cp27m-macosx_10_6_intel.whl Collecting pynacl > = 1.0.1 ( from paramiko - > ansible ) Downloading https : //files.pythonhosted.org/packages/51/83/2db5b919bf9848fe25d301225a16faabc378419e7eaf00da0b7d200fe801/PyNaCl-1.3.0-cp27-cp27m-macosx_10_6_intel.whl (283kB) 100 % | -------------------------------- | 286kB 12.7MB / s Collecting pyasn1 > = 0.1.7 ( from paramiko - > ansible ) Downloading https : //files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl (73kB) 100 % | -------------------------------- | 81kB 12.7MB / s Collecting bcrypt > = 3.1.3 ( from paramiko - > ansible ) Downloading https : //files.pythonhosted.org/packages/14/1b/f6f05b80783ff84c58bca5f2b7a4cef7c02570e4bb2e40d326abb2ba41d3/bcrypt-3.1.6-cp27-cp27m-macosx_10_6_intel.whl (53kB) 100 % | -------------------------------- | 61kB 12.9MB / s Collecting asn1crypto > = 0.21.0 ( from cryptography - > ansible ) Downloading https : //files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB) 100 % | -------------------------------- | 102kB 13.0MB / s Collecting enum34 ; python_version < "3" ( from cryptography - > ansible ) Downloading https : //files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl Collecting ipaddress ; python_version < "3" ( from cryptography - > ansible ) Downloading https : //files.pythonhosted.org/packages/fc/d0/7fc3a811e011d4b388be48a0e381db8d990042df54aa4ef4599a31d39853/ipaddress-1.0.22-py2.py3-none-any.whl Collecting cffi ! = 1.11.3 , > = 1.8 ( from cryptography - > ansible ) Downloading https : //files.pythonhosted.org/packages/b2/03/8c9052bfb8fd8f40eead289731b21e5b82573cecd6d4366bfa7b50769bf0/cffi-1.12.1-cp27-cp27m-macosx_10_6_intel.whl (244kB) 100 % | -------------------------------- | 245kB 5.2MB / s Requirement already satisfied : six > = 1.4.1 in / System / Library / Frameworks / Python . framework / Versions / 2.7 / Extras / lib / python ( from cryptography - > ansible ) ( 1.4.1 ) Collecting pycparser ( from cffi ! = 1.11.3 , > = 1.8 - > cryptography - > ansible ) Downloading https : //files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB) 100 % | -------------------------------- | 163kB 5.9MB / s Installing collected packages : MarkupSafe , jinja2 , PyYAML , asn1crypto , enum34 , ipaddress , pycparser , cffi , cryptography , pynacl , pyasn1 , bcrypt , paramiko , ansible Running setup . py install for PyYAML . . . done Running setup . py install for pycparser . . . done Running setup . py install for ansible . . . done Successfully installed MarkupSafe - 1.1.0 PyYAML - 3.13 ansible - 2.7.8 asn1crypto - 0.24.0 bcrypt - 3.1.6 cffi - 1.12.1 cryptography - 2.5 enum34 - 1.1.6 ipaddress - 1.0.22 jinja2 - 2.10 paramiko - 2.4.2 pyasn1 - 0.4.5 pycparser - 2.19 pynacl - 1.3.0 |
Pasul 3.
Să verificăm versiunea Ansible pe macOS.
- Comanda:
ansible --version
1 2 3 4 5 6 7 |
bash - 3.2 $ ansible -- version ansible 2.7.8 config file = None configured module search path = [ u '/Users/ashah/.ansible/plugins/modules' , u '/usr/share/ansible/plugins/modules' ] ansible python module location = / Library / Python / 2.7 / site - packages / ansible executable location = / usr / local / bin / ansible python version = 2.7.10 ( default , Aug 17 2018 , 19 : 45 : 58 ) [ GCC 4.2.1 Compatible Apple LLVM 10.0.0 ( clang - 1000.0.42 ) ] |
Asta e.
Ați instalat cu succes Ansible pe sistemul dvs. macOS. Anunțați-mă dacă vă confruntați cu vreo problemă la rularea Ansible pe gazda dvs.
Ce urmeaza?
Instalați Ansible pe linia de comandă a sistemului de operare Linux Ubuntu.