%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /etc/ansible/roles/common/tasks/
Upload File :
Create Path :
Current File : //etc/ansible/roles/common/tasks/time.yml

---
# 1. set time on poll machine by master server value
# 2. run ntpd daemon
# !!! replica, csync, ntlm depends on it
- name: timezone - get information for pool
  time_facts: option=status
  delegate_to: 127.0.0.1
  tags: time_facts

- name: timezone - set facts
  set_fact:
    bx_tz: "{{ hostvars[inventory_hostname]['tz'] }}"
    bx_tz_default: "{{ hostvars[inventory_hostname]['tz_default'] }}"
    bx_tz_php: "{{ hostvars[inventory_hostname]['tz_php'] }}"
  tags: time_facts

- name: timezone - debug info
  debug: msg="timezone will be set to default value tz={{ bx_tz }}"
  when: bx_tz_default == 'True'
  tags: time_facts

- name: timezone - set /etc/sysconfig/clock
  template: src=clock.j2 dest=/etc/sysconfig/clock owner=root group=root mode=0644
  tags: timezone
  notify: restart mysqld

- name: timezone - set /etc/localtime
  file: src=/usr/share/zoneinfo/{{ bx_tz }} dest=/etc/localtime state=link force=yes
  tags: timezone
  notify: restart mysqld

- name: ntpd - install packages
  yum: pkg={{ item }} state=present 
  with_items:
    - ntp
    - ntpdate
  tags: ntpd

- name: ntpd - ensure service started
  service: name=ntpd state=started enabled=yes
  tags: ntpd

- name: ntpd - restarted
  service: name=ntpd state=restarted
  tags: ntpd

# php configuration
- name: create update time string
  shell: date +"%Y-%m-%d %H:%M:%S"
  register: phpupdate_date
  when: "'bitrix-web' in group_names and bx_tz != bx_tz_php"
  tags: php_configure

- name: delete artifacts from /etc/php.d/bitrixenv.ini
  lineinfile: dest=/etc/php.d/bitrixenv.ini state=absent regexp=' by ansible manager at '
  tags: php_configure
  notify: restart httpd
  when: "'bitrix-web' in group_names and bx_tz != bx_tz_php"

- name: update /etc/php.d/bitrixenv.ini - ansible comment
  lineinfile: dest=/etc/php.d/bitrixenv.ini state=present regexp='date.timezone'
    line=';set timezone={{ bx_tz }} by ansible manager at {{ phpupdate_date.stdout }}'
  tags: php_configure
  notify: restart httpd
  when: "'bitrix-web' in group_names and bx_tz != bx_tz_php"

- name: update /etc/php.d/bitrixenv.ini - time string
  lineinfile: dest=/etc/php.d/bitrixenv.ini state=present regexp='date.timezone'
    line='date.timezone = {{ bx_tz }}'
  tags: php_configure
  notify: restart httpd
  when: "'bitrix-web' in group_names and bx_tz != bx_tz_php"

- name: restart httpd-scale
  shell: /opt/webdir/bin/restart_httpd-scale.sh
  args:
    creates: /opt/webdir/logs/restart_httpd-scale.request
  when: ansible_distribution == "CentOS"
    and ansible_distribution_major_version == "7"

- name: restart httpd
  service:
    name: httpd
    state: restarted
  when: ansible_distribution == "CentOS"
    and ansible_distribution_major_version == "6"

Zerion Mini Shell 1.0