tips:ansible

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tips:ansible [2022/09/09 09:52] – created sscipionitips:ansible [2022/09/09 11:09] (current) – [playbook] igor
Line 22: Line 22:
        msg: Hello world        msg: Hello world
  
-</code>+</file>
  
 <code> <code>
Line 28: Line 28:
 </code> </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 ===== ===== install =====
Line 38: Line 73:
  
 <file ini /etc/ansible/hosts> <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] [nodes]
 10.45.0.1 10.45.0.1
  • tips/ansible.1662709931.txt.gz
  • Last modified: 2022/09/09 09:52
  • by sscipioni