Failure to comply with the rules for playing notifications

I'm currently switching from a puppet to Ansible , and I'm a little confused with some concepts, or at least how ansible works.

Setup Information:

I use examples from Ansible Best Practices and structured my project, similar to several roles (playbooks) and so on.

I use Vagrant for training, and the Saucy64 VBox box.

Where the confusion occurs:

When I provide and I run it, tasks start and then the notification stack.

Example:

Last task:

TASK: [mysql | delete anonymous MySQL server user for localhost] ************** 
<127.0.0.1> REMOTE_MODULE mysql_user user='' state=absent 
changed: [default] => {"changed": true, "item": "", "user": ""}

Then the first notice:

NOTIFIED: [timezone | update tzdata] ****************************************** 
<127.0.0.1> REMOTE_MODULE command /usr/sbin/dpkg-reconfigure --frontend noninteractive tzdata
changed: [default] => {"changed": true, "cmd": ["/usr/sbin/dpkg-reconfigure", "--frontend", "noninteractive", "tzdata"], "delta": "0:00:00.224081", "end": "2014-02-03 22:34:48.508961", "item": "", "rc": 0, "start": "2014-02-03 22:34:48.284880", "stderr": "\nCurrent default time zone: 'Europe/Amsterdam'\nLocal time is now:      Mon Feb  3 22:34:48 CET 2014.\nUniversal Time is now:  Mon Feb  3 21:34:48 UTC 2014.", "stdout": ""}

Now everything is all right. As roles increase more and more notifications.

Now a problem arises.

, . ! , , !

, vhosts apache apache, .

():

- name: Install Apache Modules
  notify: Restart Apache

- name: Enable Vhosts
  notify: Reload Apache

- name: Install PHP
  command: GGGGGG # throws an error

:

  • Apache
  • Vhosts
  • PHP
  • Script
  • ( ?)

, Ansible (no! *) , , apache, apache, . , .

. , , , , apache , , , . .

script php - . ?

: Ansible , "/", , . , , , , apache, :

  • ansible ssh
  • script

, , - Ansible?

"" // ?

  • , . *
+4
2

, Ansible Puppet. , Ansible ( Chef), . , , Puppet , , .

, , Ansible script , . , , - . - :

- name: My cool playbook
  hosts: all

  vars:
      force_tasks: 0

  tasks:
    - name: Apache install
      action: apt pkg=$item state=latest
      with_items:
       - apache2
       - apache2-mpm-prefork

    - name: Restart apache
      action: service name=apache2 state=restart
      when: force_tasks

force_tasks :

ansible-playbook -i my_inventory -e "force_tasks=True" my_ansible_playbook.yml

.

+3

-force-handlers. Ansible , , . Ansible ansible.cfg, . , .

0

Source: https://habr.com/ru/post/1525119/


All Articles