Ansible Bootstrap: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 13: Zeile 13:
 
  inventory = inventory
 
  inventory = inventory
 
  private_key_file = ~/.ssh/id_rsa
 
  private_key_file = ~/.ssh/id_rsa
roles_path = $HOME/ansible/roles
 
 
<span id="hosts"></span>
 
<span id="hosts"></span>
 +
 
= Hosts =
 
= Hosts =
  

Version vom 10. Februar 2023, 10:09 Uhr

Einstellung

Es liegt hier alles unter ~/ansible

Ansible-Konfigurationsdatei

  • cat ansible.cfg
[defaults]
inventory = inventory
private_key_file = ~/.ssh/id_rsa

Hosts

  • cat inventory
10.82.243.96
10.82.243.97
10.82.243.98
10.82.243.22

[all:vars]
ansible_ssh_pass=123Start$
ansible_become_pass=123Start$
ansible_become_method=su

Playbook

  • cat bootstrap.yml
---
- name: Grundlegende Einrichtung der Hosts
  hosts: all
  become: true
  tasks:
    - name: Füge Benutzer xinux zur Gruppe sudo hinzu
      user:
        name: xinux
        groups: sudo
        append: true
    - name: Hinterlege SSH publickey bei den Benutzern xinux und root
      authorized_key:
        user: "Vorlage:Item"
        state: present
        key: "Vorlage:Lookup('file', '/path/to/public key')"
      with_items:
        - xinux
        - root

Ausführen

  • ansible-playbook bootstrap.yml