Show pageOld revisionsBacklinksAdd to bookExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== ansible ====== ===== basic op ===== <code bash> ansible all --list-hosts ansible all -m ping </code> ===== playbook ===== <file yaml helloworld.yaml> - name: helloworld hosts: nodes tasks: - name: Ping my hosts ansible.builtin.ping: - name: Print message ansible.builtin.debug: msg: Hello world </file> <code> ansible-playbook helloworld.yaml </code> <file yaml addkeys.yaml> - name: Add ssh key to ubuntu user hosts: nodes tasks: - name: Set authorized key took from file authorized_key: user: ubuntu state: present key: "{{ lookup('file', '/root/.ssh/id_ed25519.pub') }}" </file> <code> ansible-playbook addkeys.yaml </code> Installa ed avvia un pacchetto (per esempio ''glusterfs'') <file yaml glusterfs.yaml> - name: Install glusterFS hosts: nodes tasks: - name: Install package ansible.builtin.apt: update_cache: yes cache_valid_time: 86400 name: glusterfs-server - name: Start service ansible.builtin.systemd: state: started name: glusterd </file> <code> ansible-playbook glusterfs.yaml </code> ===== install ===== <code bash> python3 -m pip install --user ansible </code> ===== config ===== <file ini /etc/ansible/hosts> [all:vars] ansible_user='ubuntu' ansible_become=yes ansible_become_method=sudo ansible_python_interpreter='/usr/bin/env python3' [nodes] 10.45.0.1 10.45.0.2 10.45.0.3 10.45.0.4 10.45.0.5 </file> tips/ansible.txt Last modified: 2022/09/09 11:09by igor