“Ansible包管理模块”的版本间的差异
跳到导航
跳到搜索
(创建页面,内容为“=apt module= == playbook== == 直接命令行== ansible用户 最好为root ansible pi3 -m apt -a "name=links state=present" # install ansible pi3 -m apt…”) |
|||
第1行: | 第1行: | ||
=apt module= | =apt module= | ||
== playbook== | == playbook== | ||
+ | <pre> | ||
+ | |||
+ | cat /etc/ansible/hosts | ||
+ | [tmp] | ||
+ | 192.168.10.33 ansible_user=eva | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | cat /etc/ansible/links.yml | ||
+ | --- | ||
+ | - hosts: tmp | ||
+ | become: yes | ||
+ | become_method: sudo | ||
+ | remote_user: eva | ||
+ | tasks: | ||
+ | - name: Install links (state=present is optional) | ||
+ | ansible.builtin.apt: | ||
+ | name: links | ||
+ | state: present | ||
+ | |||
+ | ansible-playbook -C links.yml && ansible-playbook links.yml | ||
+ | </pre> | ||
+ | |||
+ | https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html | ||
== 直接命令行== | == 直接命令行== |
2023年7月4日 (二) 07:38的版本
apt module
playbook
cat /etc/ansible/hosts [tmp] 192.168.10.33 ansible_user=eva cat /etc/ansible/links.yml --- - hosts: tmp become: yes become_method: sudo remote_user: eva tasks: - name: Install links (state=present is optional) ansible.builtin.apt: name: links state: present ansible-playbook -C links.yml && ansible-playbook links.yml
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html
直接命令行
ansible用户 最好为root
ansible pi3 -m apt -a "name=links state=present" # install ansible pi3 -m apt -a "name=links state=absent" #remove