Files
ansible-example/playbook.yml

11 lines
1.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--- # ansible-playbook -i hosts.ini playbook.yml
- hosts: debian_servers
become: true # 的作用是提升任务的执行权限。具体来说它允许任务在目标主机上以不同于当前用户的身份运行通常是以超级用户root的身份。这在需要执行需要更高权限的操作时非常有用例如安装软件包、修改系统配置文件等。
tasks:
- name: Update all packages
apt: # 这是 Ansible 的一个模块,用于管理 APT 包管理系统。
update_cache: yes # 这会更新 APT 包管理系统的缓存,相当于运行 sudo apt-get update。
upgrade: dist # 这会执行一个发行版升级,相当于运行 sudo apt-get dist-upgrade。
vars: # Python 解释器警告: 输出中有关于 Python 解释器的警告。这并不影响 Ansible 的执行,但提醒你未来可能会因安装不同版本的 Python 而导致路径变更。若需消除警告,可以显式指定使用的 Python 解释器。在 Playbook 中添加如下变量:
ansible_python_interpreter: /usr/bin/python3