ansible

warning: Creating default object from empty value in /data/web/1/000/027/003/273448/htdocs/panticz.de/modules/taxonomy/taxonomy.pages.inc on line 33.

Rundeck Ansible Plugin

https://github.com/Batix/rundeck-ansible-plugin

https://github.com/Batix/rundeck-ansible-plugin/releases/latest

wget https://github.com/Batix/rundeck-ansible-plugin/releases/download/2.0.2/ansible-plugin-2.0.2.jar -P /var/lib/rundeck/libext/

* Create a new project
http:///resources/createProject

Project Name: Ansible
Default Node Executor: "Ansible Ad-Hoc Node Executor"
Executable: /bin/bash
SSH Connection > SSH Authentication: privateKey

Default Node File Copier
SSH Connection: privateKey

apt-get install ansible

Debian / Ubuntu mass dist-upgrade with Ansible (with fallback and logging)

ansible-playbook dist-upgrade.yml -i your_inventory [-l host_name]

---
- hosts:
    all
  gather_facts: no
  vars:
    verbose: false
    log_dir: "log/dist-upgrade/{{ inventory_hostname }}"
  pre_tasks:
    - block:
        - setup:
      rescue:
        - name: "Install required python-minimal package"
          raw: "apt-get update && apt-get install -y --force-yes python-apt python-minimal"
        - setup:
  tasks:
    - name: Update packages
      apt:
        update_cache: yes
        upgrade: dist
        autoremove: yes
      register: output

    - name: Check changes
      set_fact:
        updated: true
      when: not output.stdout | search("0 upgraded, 0 newly installed")

    - name: Display changes
      debug:
        msg: "{{ output.stdout_lines }}"
      when: verbose or updated is defined

    - block:
      - name: "Create log directory"
        file:
          path: "{{ log_dir }}"
          state: directory
        changed_when: false

      - name: "Write changes to logfile"
        copy:
          content: "{{ output.stdout }}"
          dest: "{{ log_dir }}/dist-upgrade_{{ ansible_date_time.iso8601 }}.log"
        changed_when: false

      when: updated is defined
      connection: local

Ansible templates

{% for host in groups['db_servers'] %}
{{ host }}
{{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}
{% endfor %}

{% elif student.department.upper() != "MATHS DEPARTMENT" %}
Maths department
{% endif %}

# generate SSH config
{% for host in groups['vm.example.com'] %}
Host {{ host }}
Hostname {{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}
{% endfor %}

# Links
http://jinja.pocoo.org/docs/dev/templates/#line-statements

Ansible

Ansible playbook repository
https://github.com/panticz/ansible

Install Ansible Server
http://www.panticz.de/install-ansible

Ansible syntax (YAML)
http://docs.ansible.com/ansible/YAMLSyntax.html

Configuration files
http://docs.ansible.com/ansible/intro_configuration.html#host-key-checking
/etc/ansible/ansible.cfg - global default configuration
~/.ansible.cfg - local global configuration
/etc/ansible/hosts - default inventory file

Ignore host key
# inventory
[all:vars]

Syndicate content