- name: set vars for server
  set_fact:
    hostname: "mail"
    X: "{{ octet4 | int - 100 }}"
  when: octet4 | int >= 100

- name: set vars for mail
  set_fact:
    hostname: "server"
    X: "{{ octet4 }}"
  when: octet4 | int < 100

- name: echo variables
  debug:
    msg: octet4 is {{ octet4 }}, X is {{ X }}, hostname is {{hostname}}

- name: Create hosts file
  template: src=hosts.j2 dest=/etc/hosts
  notify:
    - restart system

- name: Create resolv.conf file
  template: src=resolv.conf.j2 dest=/etc/resolv.conf
  notify:
    - restart system

- name: Create hostname file
  template: src=hostname.j2 dest=/etc/hostname
  notify:
    - restart system

- name: Create interfaces file
  template: src=interfaces.j2 dest=/etc/network/interfaces
  notify:
    - restart system

- name: Set timezone to Europe/Moscow
  timezone:
    name: Europe/Moscow

