■ はじめに
2019/05/16 に Ansible 2.8.0 がリリースされました。多数のモジュールの追加や、機能追加、バグ修正、機能削除、機能の非推奨化、仕様変更が含まれています。
大きめなトピックとしては以下のものがあります。
- Python のインタープリターを探索する Interpreter Discovery 機能の追加(日本語解説)
- 例えば、デフォルトで python コマンドがない RHEL8 などで活用
- Ansible Collections と名前空間の実験的サポート
この記事では、CHANGELOG や Porting Guide を中心に、気になった点と関連URLをまとめます。 特性が分かるように、主観ですが「便利」「地味に便利」「ちょっと注意」というタグのようなものをつけています。
また、★ 印があるものは、2019/05/31 開催予定の Ansible Night in Osaka 2019.05でもご紹介する予定です。リモート参加枠もありますので、よろしければご参加ください。
[2019/06/01追記] 当日の発表資料です。
www.slideshare.net
特に CHANGELOG は、それでだけ見てもどういったことが分かりにくいものもありますので、関連URLも参考にしていただくと良いかと思います。Ansible 2.8 へのアップデート判断の材料になれば幸いです。
■ 変更
全体
★ PLAY RECAP に
skipped
、rescued
、ignored
追加Add stats on rescued/ignored tasks to play recap
- https://docs.ansible.com/ansible/2.8/porting_guides/porting_guide_2.8.html#plugins
- https://github.com/ansible/ansible/pull/48418
- 地味に便利
★ retry file の生成がデフォルトで無効に
retry_files_enabled now defaults to False instead of True.
- https://docs.ansible.com/ansible/2.8/porting_guides/porting_guide_2.8.html#retry-file-creation-default
- 地味に便利
権限昇格
- ★
ansible-playbook
コマンドの--sudo
などの権限昇格方式固有の引数は削除されて--become
に統一become - The deprecated CLI arguments for
--sudo
,--sudo-user
,--ask-sudo-pass
,-su
,--su-user
, and--ask-su-pass
have been removed, in favor of the more generic--become
,--become-user
,--become-method
, and--ask-become-pass
.- https://docs.ansible.com/ansible/2.8/cli/ansible.html
- https://docs.ansible.com/ansible/2.8/cli/ansible-playbook.html
- ちょっと注意
- become パスワードプロンプトがデフォルトで
BECOME password:
にChange the default value for
AGNOSTIC_BECOME_PROMPT
toTrue
so become prompts displayBECOME password:
regardless of the become method used. To display the become method in the prompt (for example,SUDO password:
), set this config option toFalse
.- https://docs.ansible.com/ansible/2.8/reference_appendices/config.html#agnostic-become-prompt
- ちょっと注意
- become が plugin 化
become functionality has been migrated to a plugin architecture, to allow customization of become functionality and 3rd party become methods
- https://docs.ansible.com/ansible/2.8/plugins/become.html
- https://github.com/ansible/ansible/pull/50991
ansible-galaxy
ansible-galaxy install
サブコマンドに--force-with-deps
オプション追加allow user to force install a role and it's dependencies
- https://docs.ansible.com/ansible/2.8/cli/ansible-galaxy.html#cmdoption-ansible-galaxy-install-force-with-deps
制御 / jinja2 / 変数
- import_tasks 自体を
notify
で呼び出しできなくなる - loop 内 ループインデックスなどが利用可能に(
ansible_loop.index0
など)Add new
extended
option to return extended loop information- https://docs.ansible.com/ansible/devel/user_guide/playbooks_loops.html#defining-inner-and-outer-variable-names-with-loop-var
- 地味に便利
- ★ jinja2 で現在時刻を
now()
で取得可能にAdd
now()
function for getting the current time- https://docs.ansible.com/ansible/devel/user_guide/playbooks_templating.htmlhttps://docs.ansible.com/ansible/2.8/user_guide/playbooks_templating.html#get-the-current-time
- 地味に便利
- ★ 未定義変数へのアクセス柔軟性が向上
- 入れ子になった未定義のキー、インデックスに
default
フィルターを利用可能に accesses to keys/indices on an undefined value now return further undefined values rather than throwing an exception
- https://docs.ansible.com/ansible/2.8/porting_guides/porting_guide_2.8.html#jinja-undefined-values
- 地味に便利
- 入れ子になった未定義のキー、インデックスに
inclide_role
、import_role
でfrom_handlers
オプションが利用可能にadd from_handblers option to include_role/import_role
- https://docs.ansible.com/ansible/2.8/modules/import_role_module.html
- https://docs.ansible.com/ansible/2.8/modules/include_role_module.html
- ★ register 変数名等でテンプレートが使用不可に
add facility for playbook attributes that are not templatable, i.e register
- https://github.com/ansible/ansible/pull/49737/files
- ちょっと注意
- PLAY の名前を示す
ansible_play_name
マジック変数が追加Add
ansible_play_name
magic var (https://github.com/ansible/ansible/issues/11349)- https://docs.ansible.com/ansible/2.8/reference_appendices/special_variables.html#magic
- 地味に便利
- 認証情報の変数名の標準化 (ansible_user、ansible_password など)
- ★ 文字列変換時の WARNING
- モジュールオプションに指定した値の文字列への変換時にデフォルトで WARNING
add
STRING_CONVERSION_ACTION
option to warn, error, or ignore when a module parameter is string type but the value from YAML is not a string type and it is converted (https://github.com/ansible/ansible/issues/50503)- https://docs.ansible.com/ansible/2.8/porting_guides/porting_guide_2.8.html#module-option-conversion-to-string
- https://docs.ansible.com/ansible/2.8/reference_appendices/config.html#string-conversion-action
- https://twitter.com/akira6592/status/1122151424920395776
- ちょっと注意
- notify で handler 名を呼び出す際、中間一致で呼び出してしまう
インベントリ
- ★ Netbox をインベントリとして利用可能に
- Gitlab runners をインベントリとして利用可能に
Ansible dynamic inventory plugin for Gitlab runners.
- https://docs.ansible.com/ansible/2.8/plugins/inventory/gitlab_runners.html
- 便利そう
- ★ グループ名に利用できる文字の厳格化
add toggle to allow user to override invalid group character filter
- https://docs.ansible.com/ansible/2.8/reference_appendices/config.html#transform-invalid-group-chars
- https://github.com/ansible/ansible/pull/52748
- ちょっと注意
環境
- ★ paramiko が同梱されなくなる
paramiko is now optional. There is no compat package on certain platforms to worry about.
- https://docs.ansible.com/ansible/2.8/installation_guide/intro_installation.html
In order to use the paramiko connection plugin or modules that require paramiko, install the required module
- ちょっと注意
- macOS でコネクションプラグインに smart の場合、paramiko の代わりに ssh をデフォルトで利用
- change default connection plugin on macOS when using smart mode to ssh instead of paramiko (https://github.com/ansible/ansible/pull/54738)
- Python Interpreter Discovery
The first time a Python module runs on a target, Ansible will attempt to discover the proper default Python interpreter to use for the target platform/version (instead of immediately defaulting to
/usr/bin/python
). You can override this behavior by settingansible_python_interpreter
or via config. (see https://github.com/ansible/ansible/pull/50163)- https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.htmlhttps://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html#python-interpreter-discovery
- https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.html
- (日本語解説)https://rheb.hatenablog.com/entry/ansible_interpreter_discovery
- 便利そう
- Ansible Collections
Experimental support for Ansible Collections and content namespacing - Ansible content can now be packaged in a collection and addressed via namespaces. This allows for easier sharing, distribution, and installation of bundled modules/roles/plugins, and consistent rules for accessing specific content via namespaces.
- http://redhat.lookbookhq.com/ansiblenight_190417
- https://docs.ansible.com/ansible/2.8/reference_appendices/config.html#collections-paths
- https://docs.ansible.com/ansible/devel/collections_tech_preview.html
ファイル
- copy モジュールで
remote_src
有効時でも再帰コピーをサポートsupport recursive copying with remote_src
- https://docs.ansible.com/ansible/2.8/modules/copy_module.html#copy-module
- 地味に便利
システム
- service_facts モジュールで
disabled
なサービスの情報も取得可能にservice_facts - provide service state and status information about disabled systemd service units
- https://docs.ansible.com/ansible/2.8/modules/service_facts_module.html
- 地味に便利
Windows
★ Windows ホストへの SSH 接続サポート(experimental)
Added experimental support for connecting to Windows hosts over SSH using
ansible_shell_type=cmd
or `ansible_shell_type=powershell``- https://docs.ansible.com/ansible/2.8/user_guide/windows_setup.html#windows-ssh-setup
- https://docs.ansible.com/ansible/2.8/user_guide/windows_faq.html#can-i-connect-to-windows-hosts-over-ssh
- https://speakerdeck.com/hiyokotaisa/rhtn-ansible-2-dot-8-x-windows (日本語)
- 便利そう
パスワードなしの権限昇格
windows become - Add support for passwordless become.
- https://docs.ansible.com/ansible/2.8/user_guide/become.html#become-without-setting-a-password
- 便利そう
ネットワーク
- *_config にバックアップファイルのパスを変更できる
backup_options
オプション追加Add configurable backup path option support for network config modules
- ios_coffig の例
- 地味に便利
- persistent command_timeout のデフォルト値が変更 (10秒から30秒へ)
Increase the default persistent command_timeout value from 10 to 30 seconds to reduce frequent timeout issues.
- network_cli の例
- https://github.com/ansible/ansible/pull/51555
- panos_* (PaloAlto) モジュールが 非推奨(deprecated)に
panos use the Palo Alto Networks Ansible Galaxy role instead. - https://docs.ansible.com/ansible/2.8/porting_guides/porting_guide_2.8.html#deprecation-notices
- cli_config モジュール にコンフィグバックアップする
backup
オプション追加 - ios_facts モジュールで config 取得時に
Building configuration
などの不要な行を削除するように (2019/09/24 追記)- CHANGELOG だがこちらの PR https://github.com/ansible/ansible/pull/48047
- 2.7 まで
- 2.8 から
- 地味に便利
■ 新規プラグイン
コネクションプラグイン
- vmware_tools
- napalm
Provides persistent connection using NAPALM
- https://docs.ansible.com/ansible/2.8/plugins/connection/napalm.html
- podman
Interact with an existing podman container
- https://docs.ansible.com/ansible/2.8/plugins/connection/podman.html
インベントリプラグイン
- docker_swarm
Ansible dynamic inventory plugin for Docker swarm nodes.
- https://docs.ansible.com/ansible/2.8/plugins/inventory/docker_swarm.html
- gitlab_runners
Ansible dynamic inventory plugin for Gitlab runners.
- https://docs.ansible.com/ansible/2.8/plugins/inventory/gitlab_runners.html
- netbox
Lookup
- aws_secret
Look up secrets stored in AWS Secrets Manager.
- https://docs.ansible.com/ansible/2.8/plugins/lookup/aws_secret.html
- rabbitmq
Retrieve messages from an AMQP/AMQPS RabbitMQ queue.
- https://docs.ansible.com/ansible/2.8/plugins/lookup/rabbitmq.html
■ 新規モジュール
Cloud
- ali_* 新規対応 (Alicloud)
- podman_* 新規対応
Files
Monitoring
- zabbix_action
Create/Delete/Update Zabbix actions
- https://docs.ansible.com/ansible/2.8/modules/zabbix_action_module.html
- zabbix_map
Create/update/delete Zabbix maps
- https://docs.ansible.com/ansible/2.8/modules/zabbix_map_module.html
Net Tools
Network
- checkpoint_* 新規対応
- eos_bgp
Configure global BGP protocol settings on Arista EOS.
- https://docs.ansible.com/ansible/2.8/modules/eos_bgp_module.html
- 便利そう
- fortios_* 200モジュール以上追加
- frr_* 新規対応 (FRRouting)
- ★ ios_bgp
- ios_ntp
Manages core NTP configuration.
- https://docs.ansible.com/ansible/2.8/modules/ios_ntp_module.html
- iosxr_bgp
- restconf_* 新規対応
- junos_config に
commit_check
オプション追加
Notification
- rabbitmq_publish
Publish a message to a RabbitMQ queue.
- https://docs.ansible.com/ansible/2.8/modules/rabbitmq_publish_module.html
Source Control
- gitlab_runner
Create, modify and delete GitLab Runners.
- https://docs.ansible.com/ansible/2.8/modules/gitlab_runner_module.html
System
- gather_facts
Gathers facts about remote hosts
- https://docs.ansible.com/ansible/2.8/modules/gather_facts_module.html
■ まとめ
Ansible 2.8.0 、CHANGELOG や Porting Guide を中心に、気になった点と関連URLをまとめました。
基本的には便利になりますが、非推奨として残しておいたものの削除や、paramiko の非同梱化など、ちょっとした注意点もありました。