got it resolved. i used the lineinfile module to replace with the timezone
- lineinfile: path: /etc/sysconfig/clock regexp: 'ZONE=' line: 'ZONE="{{ timezone }}"' state: present backup: yes when: current_zone.stdout != '{{ timezone }}' On Thursday, 24 September 2020 at 12:04:03 UTC-4 Vineeth Joseph Abraham wrote: > Hi > > Following is the script to change the timezone in ec2-instance > > vars: > > - timezone: Canada/Eastern > > - name: Check current timezone > > shell: awk -F\" '{ print $2}' /etc/sysconfig/clock > > register: current_zone > > changed_when: False > > > > - name: Set EST timezone > > file: src=/usr/share/zoneinfo/{{ timezone }} dest=/etc/localtime > state=link force=yes > > when: current_zone.stdout != '{{ timezone }}' > > > i wanted to replace the following /etc/sysconfig/clock UTC entry with > variable value defined above. Can someone help me with steps in ansible or > shell command to replace the zone ? Thanks in advance. > > $ cat /etc/sysconfig/clock > ZONE="UTC" # UTC to be replaced with Canada/Eastern > UTC=true > > > > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/86c36aa1-4d0b-4480-9fea-19c85e52ef19n%40googlegroups.com.