2020年3月6日現在、PyPI の Ansible リポジトリ で確認すると Ansible の最新バージョンは 2.9.6 のようです。
一方、Raspbian Buster の apt コマンドで標準リポジトリからインストールする Ansible のバージョンは 2.7.7 で少々古いです。
また、Ansible の replace モジュールドキュメント を読むと As of Ansible 2.7.10, the combined use of before and after works properly.
と書いてあり、裏を返すと replace モジュールの after と before を組み合わせて使う場合に 2.7.10 より前のバージョンでは適切に動かないようです。
今回はまずは Raspbian Buster の標準リポジトリから少々古い Ansible をインストールして、この Ansible を使って新しめの Ansible にバージョンアップしてみました。
■ 環境
- Raspberry Pi 3 Model B
- Raspbian GNU/Linux 10 (buster)
■ Raspbian Buster の標準リポジトリから少々古い Ansible をインストール
Ansible インストール
$ sudo apt udpate
$ sudo apt install ansible
バージョンを確認すると 2.7.7 でした。
$ ansible --version
ansible 2.7.7
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/pi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
■ Ansible で Ansible をバージョンアップ
今回は上の手順でインストールした古めの Ansible を使って、新しめのバージョンが用意されていると思われる Ubuntu 18.04 LTS 用 PPA リポジトリの Ansible にバージョンアップしてみました。
Playbook ファイルを準備
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
vars: | |
distrib_codename: bionic | |
connection: local | |
gather_facts: no | |
become: true | |
tasks: | |
- name: apt_key | |
apt_key: | |
url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x93C4A3FD7BB9C367 | |
state: present | |
- name: apt_repository | |
apt_repository: | |
repo: deb http://ppa.launchpad.net/ansible/ansible/ubuntu {{ distrib_codename }} main | |
filename: ubuntu-{{ distrib_codename }}-ppa-ansible | |
state: present | |
- name: apt update | |
apt: | |
update_cache: yes | |
- name: apt install | |
apt: | |
update_cache: no | |
state: latest | |
pkg: | |
- ansible |
ansible-playbook 実行
$ ansible-playbook -i localhost, pbook-update-ansible.yaml
Ansible が 2.9.4 にバージョンアップされました。
$ ansible --version
ansible 2.9.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/pi/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0]
0 件のコメント:
コメントを投稿