ansible.cfg
[student@workstation dev-tags]$ cat ansible.cfg 
[defaults]
inventory   = inventory
remote_user = devops

[privilege_escalation]
become      = true
inventory
[student@workstation dev-tags]$ cat ansible.cfg 
[defaults]
inventory   = inventory
remote_user = devops

[privilege_escalation]
become      = true
configure_mail.yml
[student@workstation dev-tags]$ cat configure_mail.yml 
---
- name: Install postfix
  yum:
    name: postfix
    state: latest
  tags:
    - server
  notify:
    - start_postfix


- name: Install dovecot
  yum:
    name: dovecot
    state: latest
  tags:
    - client
  notify:
    - start_dovecot

- name: Download main.cf configuration
  get_url:
    url: "http://materials.example.com/task_control/main.cf"
    dest: /etc/postfix/main.cf
  tags:
    - server
  notify: 
    - restart_postfix
playbook.yml
[student@workstation dev-tags]$ cat playbook.yml 
---
- hosts: all
  tasks:
    - name: Include configure_mail.yml
      include: configure_mail.yml
      when: inventory_hostname in groups['mailservers']

  handlers:
    - name: start_postfix
      service:
        name: postfix
        state: started

    - name: start_dovecot
      service:
        name: dovecot
        state: started

    - name: restart_postfix
      service:
        name: postfix
        start: restarted
  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.