pennate 发表于 2018-7-30 12:57:09

ansible学习笔记(一)

tasks:  - name: create a virtual host file for {{ vhost }}
  template: src=somefile.j2 dest=/etc/httpd/conf.d/{{ vhost }}
组合起来看下面两条示例。notify中的task被称作为handlers,它们是单独定义的,notify指定handlers的name,handlers分列了各个条目的task。  - name: template configuration file
  template: src=template.j2 dest=/etc/foo.conf
  notify:
  - restart memcached
  - restart apache
  handlers:
  - name: restart memcached
  service:name=memcached state=restarted
  - name: restart apache
  service: name=apache state=restarted
  project的目录结构示范
  site.yml
  webservers.yml
  fooservers.yml
  roles/
  common/
  files/
  templates/
  tasks/
  handlers/
  vars/
  defaults/
  meta/
  webservers/
  files/
  templates/
  tasks/
  handlers/
  vars/
  defaults/
  meta/
  在playbook中,你应该考虑这么写:
页: [1]
查看完整版本: ansible学习笔记(一)