将Mac内的Ansible 1.9版本升级到2.3版本

由于Mac中预装的Ansible版本较旧,可能是默认版本,所以我使用brew重新安装并将其升级至2.3。

环境

    • OS X Yosemite 10.10.3

 

    homebrew

执行

我要升级brew。

$ brew upgrade

建筑需要花费时间。

接下来查看并更新Ansible的版本。

$ ansible-playbook --version
ansible-playbook 1.9.2
  configured module search path = None

我将检查可以在brew中安装的ansible的版本。

$ brew info ansible
ansible: stable 2.3.1.0 (bottled), HEAD
Automate deployment, configuration, and upgrading
https://www.ansible.com/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ansible.rb
==> Dependencies
Build: pkg-config ✔
Required: libyaml ✘, openssl@1.1 ✔
==> Requirements
Required: python ✔

我将安装Ansible。

==> Downloading https://homebrew.bintray.com/bottles/ansible-2.3.1.0.yosemite.bottle.tar.gz
Already downloaded: /Users/yoshiyuki_sakamoto/Library/Caches/Homebrew/ansible-2.3.1.0.yosemite.bottle.tar.gz
==> Pouring ansible-2.3.1.0.yosemite.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-doc
/usr/local/bin/ansible-galaxy
/usr/local/bin/ansible-playbook
/usr/local/bin/ansible-pull
/usr/local/bin/ansible-vault
==> Summary
?  /usr/local/Cellar/ansible/2.3.1.0: 11,346 files, 124.4MB

然后告诉我由于已经存在 /usr/local/bin/ansible 等文件,所以不行。我会随意重命名它们。

$ cd /usr/local/bin
$ ls -la ansible*
-rwxr-xr-x  1 root  admin   7281  8  5  2015 ansible*
-rwxr-xr-x  1 root  admin  11071  8  5  2015 ansible-doc*
-rwxr-xr-x  1 root  admin  36087  8  5  2015 ansible-galaxy*
-rwxr-xr-x  1 root  admin  12976  8  5  2015 ansible-playbook*
-rwxr-xr-x  1 root  admin   9863  8  5  2015 ansible-pull*
-rwxr-xr-x  1 root  admin   7791  8  5  2015 ansible-vault*

$ mv ansible ansible19
$ mv ansible-doc ansible-doc19
$ mv ansible-galaxy ansible-galaxy19
$ mv ansible-playbook ansible-playbook19
$ mv ansible-pull ansible-pull19
$ mv ansible-vault ansible-vault19

$ ls -la ansible*
-rwxr-xr-x  1 root  admin  11071  8  5  2015 ansible-doc19*
-rwxr-xr-x  1 root  admin  36087  8  5  2015 ansible-galaxy19*
-rwxr-xr-x  1 root  admin  12976  8  5  2015 ansible-playbook19*
-rwxr-xr-x  1 root  admin   9863  8  5  2015 ansible-pull19*
-rwxr-xr-x  1 root  admin   7791  8  5  2015 ansible-vault19*
-rwxr-xr-x  1 root  admin   7281  8  5  2015 ansible19*

我会将Ansible卸载并重新安装。

$ brew remove ansible
Uninstalling /usr/local/Cellar/ansible/2.3.1.0... (11,346 files, 124.4MB)

$ brew install ansible

确认版本

$ ansible-playbook --version
ansible-playbook 2.3.1.0
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Jul 18 2017, 09:16:45) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]

变成了2.3。

广告
将在 10 秒后关闭
bannerAds