Ansible

  • Provisioning
  • Deployment
  • Tasks

Použitie

Prečo

  • Kód > Čas
  • Verzovanie
  • Komunita
  • Učenie
---
- hosts: debian
  become: true
  tasks:
    - name: Update packages list
      apt: update_cache=yes
      when: ansible_os_family == 'Debian'

    - name: List packages to upgrade (1/2)
      shell: apt list --upgradable
      register: updates
      changed_when: False
      when: ansible_os_family == 'Debian'

Konfigurácia

[all:vars]
ansible_user=daniel.plakinger
ansible_become=yes
ansible_become_method=sudo
ansible_python_interpreter='/usr/bin/python'
ansible_ssh_private_key_file=/home/veeenex/.ssh/id_fastplus.pub

[debian]
10.20.5.12
10.20.5.14
10.20.5.16
10.10.110.155

[mailing]
37.157.193.99
89.221.222.151
---
- name: Update web servers
  hosts: webservers
  remote_user: root

  tasks:
  - name: Ensure apache is at the latest version
    ansible.builtin.yum:
      name: httpd
      state: latest
  - name: Write the apache config file
    ansible.builtin.template:
      src: /srv/httpd.j2
      dest: /etc/httpd.conf

- name: Update db servers
  hosts: databases
  remote_user: root

  tasks:
  - name: Ensure postgresql is at the latest version
    ansible.builtin.yum:
      name: postgresql
      state: latest
  - name: Ensure that postgresql is started
    ansible.builtin.service:
      name: postgresql
      state: started

DEMO

Made with Slides.com