Open20

ansible-core 2.11 / ansible 4 関連メモ

コントローラーで 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.

https://twitter.com/akira6592/status/1381080342983938053

CONTROLLER_PYTHON_WARNING という設定で、非表示にもできる。デフォルトは表示。

https://docs.ansible.com/ansible/devel/reference_appendices/config.html#controller-python-warning

関連スクラップ

https://zenn.dev/akira6592/scraps/2454c658b31c48#comment-11a2606ac97cb1

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.

公式ドキュメント

https://docs.ansible.com/ansible/devel/user_guide/collections_using.html#installing-collections

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_roleinclude_rolerolespec_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.

公式ドキュメント

https://docs.ansible.com/ansible/devel/collections/ansible/builtin/import_role_module.html#parameter-rolespec_validate

Perform role argument spec validation if an argument spec is defined.

defaultは yes

ロールの metaargument_specs がサポート

必要な変数?を示せる

Add support for argument_specs data in role metadata.

公式ドキュメント

https://docs.ansible.com/ansible/devel/user_guide/playbooks_reuse_roles.html#role-argument-validation

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."

おためし

https://twitter.com/akira6592/status/1381107152987713544

--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
$ 

csvfile lookup plguin の改善

The csvfile lookup plugin now uses parse_kv() internally. As a result, multi-word search keys can now be passed.

default callback plugin でshow_task_path_on_failure オプション追加

失敗タスクのファイル名とタスク -v なしで表示されるように指定できる show_task_path_on_failure オプション。デフォルトは nono の場合は -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

https://github.com/ansible/ansible/pull/73260/
      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'

おためし

https://twitter.com/akira6592/status/1381148253899476996

dnfyum 関連

dnf - module now works under any supported Python interpreter

yum - module now works under any supported Python interpreter

作成者以外のコメントは許可されていません