Skip to content

Repository files navigation

Ansible

Ansible


  ansible all --list-hosts

  ansible all -i inventory -m ping

  ansible all -m gather_facts
  #ansible all -m gather_facts --limit 172.0.0.2

apt - Modul
Package - Modul


#apt get update:
ansible all -m apt -a update_cache=true --become --ask-become-pass

#apt get install:
ansible all -m apt -a name=cmatrix --become --ask-become-pass

#Bestimmtes Package updaten:
ansible all -m apt -a "name=snapd state=latest" --become --ask-become-pass

#apt-get dist-upgrade:
ansible all -m apt -a "upgrade=dist" --become --ask-become-pass

My first Playbook:


ansible-playbook --ask-become-pass install_apache.yml

ansible -m ansible.builtin.setup

Tags:

Ansible reserves several tag names for special behavior: always, never, tagged, untagged and all. Both always and never are mostly for use in tagging the tasks themselves, the other three are used when selecting which tags to run or skip...


#Tags im Playbook anzeigen:
ansible-playbook --list-tags site.yml

#Playbook mit Gags ausführen:
ansible-playbook --tags samba --ask-become-pass site.yml
ansible-playbook --tags "apache,db" --ask-become-pass site.yml

Playbook: Biespiele für Variablen (register)


handlers:
  - import_tasks

task:
  - name:
  ...
    register: echo_results

  - name: Show result
    debug: var=echo_result.stdout

  - name: check value of return code
    ansible.builtin.debug:
      var: bar_status.rc    
    

Collections:


ansible-galaxy collection list

About

Ansible Tutorial

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages