ansible-core 2.11 / ansible 4 関連メモ
基本情報
ansible-core devel document
ロードマップ
ansible-core 2.11 changelog
ansible-core 2.11 Portig Guide
ansible 2.11.0 の changelog を眺める
ansible 4 Porting Guide
ansible 4 changelog
ansible 4 でセットでインストールされる collection の定義
ansible 4.0.0 リリース
コントローラーで Python 3.8 以上でないと warning
Controller - Add warning for Ansible 2.11 when running a Python version older than Python 3.8 to inform users that 2.12 will only support Python 3.8 and newer on the controller. Starting with Ansible 2.11, the project will only be packaged for Python 3.8 and newer.
CONTROLLER_PYTHON_WARNING
という設定で、非表示にもできる。デフォルトは表示。
関連スクラップ
split
フィルター
ありそうでなかった 。
Filters - Add new split filter for splitting strings
ansible collection install で アップグレードできるように
これまでは --force
で無理やりやっていたが、--upgrade
オプションが追加された。
A collection can be reinstalled with new version requirements without using the --force flag. The collection's dependencies will also be updated if necessary with the new requirements. Use --upgrade to force transitive dependency updates.
It became possible to upgrade Ansible collections from Galaxy servers using the --upgrade option with ansible-galaxy collection install.
公式ドキュメント
ansible-galaxy collection install my_namespace.my_collection --upgrade
Collection 関連
It became possible to install Ansible Collections from local folders and namespaces folder similar to SCM structure with multiple collections.
気になっているけれど、よくわからず・・
ansible-galaxy collection list
コマンドで出力フォーマットを選択可能に
--format yaml
や --format json
Add --format CLI option to ansible-galaxy collection list which allows for human (default), yaml, or json.
ansible
などコマンドで --version
表示時に collection の場所が表示されるように
Add path of collection location in Ansible CLI version info.
実行例
(ac211) [admin@gitlab ~]$ ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
Current version: 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]. This feature
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
ansible [core 2.11.0rc2]
config file = None
configured module search path = ['/home/admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/admin/envs/ac211/lib64/python3.6/site-packages/ansible
ansible collection location = /home/admin/.ansible/collections:/usr/share/ansible/collections
executable location = /home/admin/envs/ac211/bin/ansible
python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
jinja version = 2.11.3
libyaml = True
import_role
、include_role
で rolespec_validate
がサポート
ロール側で argument_specs
(後述)が定義されていればチェックする。
Add new rolespec_validate option to the import/include_role modules do allow disabling of the implicit role arg validation task on a per-role basis.
公式ドキュメント
Perform role argument spec validation if an argument spec is defined.
defaultは yes
meta
で argument_specs
がサポート
ロールの 必要な変数?を示せる
Add support for argument_specs data in role metadata.
公式ドキュメント
Beginning with version 2.11, you may choose to enable role argument validation based on an argument specification defined in the role meta/main.yml file. When this argument specification is defined, a new task is inserted at the beginning of role execution that will validate the parameters supplied for the role against the specification. If the parameters fail validation, the role will fail execution.
サンプル(引用)
# roles/myapp/meta/main.yml
---
argument_specs:
# roles/myapp/tasks/main.yml entry point
main:
short_description: The main entry point for the myapp role.
options:
myapp_int:
type: "int"
required: false
default: 42
description: "The integer value, defaulting to 42."
myapp_str:
type: "str"
required: true
description: "The string value"
# roles/maypp/tasks/alternate.yml entry point
alternate:
short_description: The alternate entry point for the myapp role.
options:
myapp_int:
type: "int"
required: false
default: 1024
description: "The integer value, defaulting to 1024."
おためし
ansible-console
で extra vars が読み込み可能に
Also added extra vars cli option to console CLI.
公式ドキュメント
--version
で Jinja2 のバージョンや libyaml の有無、core としてのバージョンが表示されるように
CLI - Specify jinja version in --version output
CLI - Specify whether PyYAML includes libyaml support in version output
CLI version displays clarified as core version
おためし
$ ansible --version
ansible [core 2.11.0b1]
config file = /Users/sakana/ansible/ansible.cfg
configured module search path = ['/Users/sakana/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Users/sakana/envs/ac211/lib/python3.8/site-packages/ansible
ansible collection location = /Users/sakana/.ansible/collections:/usr/share/ansible/collections
executable location = /Users/sakana/envs/ac211/bin/ansible
python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
jinja version = 2.11.3
libyaml = True
$
複数の collection で、routing 先が変更
例
Collection routing: FortiOS content from community.network migrated to community.fortios (https://github.com/ansible/ansible/pull/73046).
template モジュールの仕様変更
Force the template module to use non-native Jinja2 (https://github.com/ansible/ansible/issues/46169)
csvfile
lookup plguin の改善
The csvfile lookup plugin now uses parse_kv() internally. As a result, multi-word search keys can now be passed.
CONDITIONAL_BARE_VARS
のデフォルトが False
に変更
2.10 で False
になった気がするが(参考)。
conditionals - change the default of CONDITIONAL_BARE_VARS to False (https://github.com/ansible/ansible/issues/70682).
show_task_path_on_failure
オプション追加
default callback plugin で失敗タスクのファイル名とタスク -v なしで表示されるように指定できる show_task_path_on_failure
オプション。デフォルトは no
。no
の場合は -vv
で表示。
default callback - add show_task_path_on_failure option to display file and line number of tasks only on failed tasks when running at normal verbosity level (https://github.com/ansible/ansible/issues/64625)
関連 PR
show_task_path_on_failure:
name: Show file path on failed tasks
description:
When a task fails, display the path to the file containing the failed task and the line number.
This information is displayed automatically for every task when running with C(-vv) or greater verbosity.
type: bool
default: no
env:
- name: ANSIBLE_SHOW_TASK_PATH_ON_FAILURE
ini:
- key: show_task_path_on_failure
section: defaults
version_added: '2.11'
おためし
ループ中の register 変数への skipped フィルターが効くように
Allow for the skipped filter to be used on a registered looped task results. (https://github.com/ansible/ansible/issues/16949)
関連PR
user
モジュールで password_expire_max
と password_expire_min
オプション追加
user - add new parameters password_expire_max and password_expire_min for controlling password expiration (https://github.com/ansible/ansible/issues/68775)
dnf
、 yum
関連
dnf - module now works under any supported Python interpreter
yum - module now works under any supported Python interpreter
ansible-playbook コマンドで collection 内の playbook を指定可能に
-t
で keyword も指定可能に
ansible-doc の
ansible-doc has new option to show keyword documentation
関連
-t
で role も指定可能に、-r
でロールパス指定
ansible-doc の
Allow inventory plugins access to extra vars by default
Allow inventory plugins access to extra vars by default