tips:ansible

This is an old revision of the document!


ansible

ansible all --list-hosts
 
ansible all -m ping
helloworld.yaml
- name: helloworld
  hosts: nodes
  tasks:
   - name: Ping my hosts
     ansible.builtin.ping:
   - name: Print message
     ansible.builtin.debug:
       msg: Hello world
ansible-playbook helloworld.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') }}"
ansible-playbook addkeys.yaml
python3 -m pip install --user ansible
/etc/ansible/hosts
[nodes]
10.45.0.1
10.45.0.2
10.45.0.3
10.45.0.4
10.45.0.5
  • tips/ansible.1662711781.txt.gz
  • Last modified: 2022/09/09 10:23
  • by igor