Message ID | 20250205-ansible_cfg3-v2-0-02620fc1e3d1@samsung.com (mailing list archive) |
---|---|
Headers | show |
Series | ansible.cfg: generate with kconfig | expand |
On Wed, Feb 05, 2025 at 07:47:15PM +0000, da.gomez@kernel.org wrote: > This series will generate the current in-tree ansible.cfg (Ansible > Configuration Settings) based on kconfig user options (kconfig menu > location: Kdevops configuration -> Ansible Configuration ->). Add > ansible.cfg Makefile target to manually generate the file, but also > append the target to the list of default make targets to make sure the > configuration file is generated. > > The first commit just keeps the ansible.cfg as is. The second changes > the current settings to: > > * Use dense [1] callback plugin instead of debug. This ensure a more > readable stdout convenient for normal operation. For CI, I recommend > setting AV=2 (Ansible Verbosity: -vv) or enable the debug plugin. We fortunatel have a way to tell if a CI configuration is being used that's just BOOTLINUX_TREE_SET_BY_CLI for kernel hacking for now, so I'd prefer if we just later add a patch to make the default setting for CIs you are making, instead of having to change CI defconfigs. Other than that: Acked-by: Luis Chamberlain <mcgrof@kernel.org> Luis
This series will generate the current in-tree ansible.cfg (Ansible Configuration Settings) based on kconfig user options (kconfig menu location: Kdevops configuration -> Ansible Configuration ->). Add ansible.cfg Makefile target to manually generate the file, but also append the target to the list of default make targets to make sure the configuration file is generated. The first commit just keeps the ansible.cfg as is. The second changes the current settings to: * Use dense [1] callback plugin instead of debug. This ensure a more readable stdout convenient for normal operation. For CI, I recommend setting AV=2 (Ansible Verbosity: -vv) or enable the debug plugin. For error/debug user situations, or kdevops/Ansible development, re-run your failed playbook with AV=1 or more. Index of callback plugins can be found here: https://docs.ansible.com/ansible/latest/collections/index_callback.html Note: More updated settings below the examples. Example running dense callback plugin with default Ansible verbosity (AV=0 or nothing): make V=1 bringup ... ansible-playbook --connection=local \ --inventory localhost, \ playbooks/gen_nodes.yml \ -e 'ansible_python_interpreter=/usr/bin/python3' \ --extra-vars=@./extra_vars.yaml PLAY 1: LOCALHOST task 1. [started TASK: Gathering Facts on localhost] task 2. [started TASK: gen_nodes : Import optional extra_args file on localhost] task 3. [started TASK: gen_nodes : Get our user on localhost] task 3: localhost task 4. [started TASK: gen_nodes : Get our primary group on localhost] task 4: localhost ... Example running dense callback plugin with Ansible verbosity level 1 (AV=1): make V=1 AV=1 bringup ... ansible-playbook -v --connection=local \ --inventory localhost, \ playbooks/gen_nodes.yml \ -e 'ansible_python_interpreter=/usr/bin/python3' \ --extra-vars=@./extra_vars.yaml Using /media/tarkir/dagomez/src/linux-kdevops/kdevops/ansible.cfg as config file PLAY 1: LOCALHOST task 1. [started TASK: Gathering Facts on localhost] task 2. [started TASK: gen_nodes : Import optional extra_args file on localhost] task 3. [started TASK: gen_nodes : Get our user on localhost] task 3: gen_nodes : Get our user changed: localhost: {"changed": true, "cmd": ["whoami"], "rc": 0, "stdout": "dagomez"} task 4. [started TASK: gen_nodes : Get our primary group on localhost] task 4: gen_nodes : Get our primary group changed: localhost: {"changed": true, "cmd": ["id", "-g", "-n"], "rc": 0, "stdout": "dagomez"} ... Example running dense callback plugin with default verbosity (AV=0), error situation (error is "forced"/"simulated"): make V=1 bringup make linux-clone PLAY 1: LOCALHOST task 1. [started TASK: Gathering Facts on localhost] task 2. [started TASK: ansible_cfg : Import optional extra_args file on localhost] task 3. [started TASK: ansible_cfg : Generate kdevops ansible.cfg on localhost] ansible-playbook --connection=local \ --inventory localhost, \ playbooks/gen_nodes.yml \ -e 'ansible_python_interpreter=/usr/bin/python3' \ --extra-vars=@./extra_vars.yaml PLAY 1: LOCALHOST task 1. [started TASK: Gathering Facts on localhost] task 2. [started TASK: gen_nodes : Import optional extra_args file on localhost] task 3. [started TASK: gen_nodes : Get our user on localhost] task 3: localhost task 4. [started TASK: gen_nodes : Get our primary group on localhost] task 4: localhost task 5. [started TASK: gen_nodes : Create guestfs directory on localhost] task 5: localhost make[1]: *** [Makefile:235: guestfs/kdevops_nodes.yaml] Error 2 make: *** [scripts/guestfs.Makefile:55: 9p_linux_clone] Error 2 Example running dense callback plugin with verbosity level 1 (AV=1), error situation (error is "forced"/"simulated"): make V=1 AV=1 bringup make linux-clone Using /media/tarkir/dagomez/src/linux-kdevops/kdevops/ansible.cfg as config file PLAY 1: LOCALHOST task 1. [started TASK: Gathering Facts on localhost] task 2. [started TASK: ansible_cfg : Import optional extra_args file on localhost] task 3. [started TASK: ansible_cfg : Generate kdevops ansible.cfg on localhost] SUMMARY localhost : ok=3 changed=0 unreachable=0 failed=0 rescued=0 ignored=0 ansible-playbook -v --connection=local \ --inventory localhost, \ playbooks/gen_nodes.yml \ -e 'ansible_python_interpreter=/usr/bin/python3' \ --extra-vars=@./extra_vars.yaml Using /media/tarkir/dagomez/src/linux-kdevops/kdevops/ansible.cfg as config file PLAY 1: LOCALHOST task 1. [started TASK: Gathering Facts on localhost] task 2. [started TASK: gen_nodes : Import optional extra_args file on localhost] task 3. [started TASK: gen_nodes : Get our user on localhost] task 3: gen_nodes : Get our user changed: localhost: {"changed": true, "cmd": ["whoami"], "rc": 0, "stdout": "dagomez"} task 4. [started TASK: gen_nodes : Get our primary group on localhost] task 4: gen_nodes : Get our primary group changed: localhost: {"changed": true, "cmd": ["id", "-g", "-n"], "rc": 0, "stdout": "dagomez"} task 5. [started TASK: gen_nodes : Create guestfs directory on localhost] task 5: gen_nodes : Create guestfs directory failed: localhost: {"msg": "The task includes an option with an undefined variable.. 'guestfs_path_err' is undefined\n\nThe error appears to be in '/media/tarkir/dagomez/src/linux-kdevops/kdevops/playbooks/roles/gen_nod es/tasks/main.yml': line 21, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Create guestfs directory\n ^ here\n"} SUMMARY localhost : ok=4 changed=2 unreachable=0 failed=1 rescued=0 ignored=0 make[1]: *** [Makefile:235: guestfs/kdevops_nodes.yaml] Error 2 make: *** [scripts/guestfs.Makefile:55: 9p_linux_clone] Error 2 * Enable show_per_host_start [3] parameter. This is a common parameter between dense and debug callback plugins. Allows to know which task is being executed rather than the current behaviour which only displays terminated tasks. * show_task_path_on_failure [4] parameter. Another commomn parameter between dense and debug callback plugins. Allows to see the path and file of the failure task when debug is -vv or greater. [1] https://docs.ansible.com/ansible/latest/collections/community/general/dense_callback.html [2] https://docs.ansible.com/ansible/latest/collections/ansible/posix/debug_callback.html#ansible-collections-ansible-posix-debug-callback [3] https://docs.ansible.com/ansible/latest/collections/community/general/dense_callback.html#parameter-show_per_host_start [4] https://docs.ansible.com/ansible/latest/collections/community/general/dense_callback.html#parameter-show_per_host_start Signed-off-by: Daniel Gomez <da.gomez@samsung.com> --- Changes in v2: - Rename KDEVOPS_ANSIBLE_CONFIG_ -> KDEVOPS_ANSIBLE_CFG_ as per Chuck's suggestion. - Add kdevops_ansible_cfg_deprecation_warnings default value. - Link to v1: https://lore.kernel.org/r/20250203-ansible_cfg3-v1-0-a9e75cd067d7@samsung.com - Update base-commit to lastest upstream main. - Update dependencies to "Fix debug mode" patches posted in the mailing list. Add ansible_cfg to the ANSIBLE WRAPPER kdevops module. --- Daniel Gomez (2): ansible.cfg: autogenerate using kconfig ansible.cfg: change defaults to minimal .gitignore | 2 + MAINTAINERS | 4 + Makefile | 17 +++- ansible.cfg | 5 - kconfigs/Kconfig.ansible_cfg | 105 +++++++++++++++++++++ kconfigs/Kconfig.kdevops | 4 + playbooks/ansible_cfg.yml | 4 + playbooks/roles/ansible_cfg/defaults/main.yml | 10 ++ playbooks/roles/ansible_cfg/tasks/main.yml | 17 ++++ .../roles/ansible_cfg/templates/ansible.cfg.j2 | 14 +++ 10 files changed, 173 insertions(+), 9 deletions(-) --- base-commit: bcea53d0710cc0722520430277c80279e90e0863 change-id: 20250203-ansible_cfg3-3ad08ef2243b prerequisite-change-id: 20250131-fix-dbg-fe4b275d90c7:v1 prerequisite-patch-id: dcbe4e784cf81c8863050d2829598e131b51a7ff prerequisite-patch-id: 149905762e9801eb6da1872f6751cf430b9f0dda prerequisite-patch-id: 8ea8b7694168bdae29156ab0c4696f0bac47815d Best regards,