---

# TODO: add task with no_log to check if genfstab already finished

- name: generate fstab output
  changed_when: false
  command: genfstab -pU /mnt
  register: c

- name: update fstab file
  blockinfile: block={{ c.stdout }} dest=/mnt/etc/fstab

- name: uncomment locales
  lineinfile: backrefs=yes
              dest=/mnt/etc/locale.gen
              line=\1
              regexp="^#({{ locale }}.{{ charset }} {{ charset }})"
  register: lif

- name: generate locales
  command: locale-gen
  when: lif | changed

- name: set locale
  lineinfile: create=yes dest=/mnt/etc/locale.conf line=LANG={{ locale }}.{{ charset }}

- name: set timezone
  file: path=/mnt/etc/localtime src=/usr/share/zoneinfo/{{ timezone }} state=link

- name: create new initial ram disk
  command: creates=/mnt/boot/initramfs-linux.img arch-chroot /mnt mkinitcpio -p linux

- name: check root password
  changed_when: false
  register: s
  shell: arch-chroot /mnt passwd -S | cut -d ' ' -f 2

- name: set root password
  shell: printf "{{ password }}\n{{ password }}" | arch-chroot /mnt passwd
  when: s.stdout == "NP"

---

# TODO: add task with no_log to check if genfstab already finished

- name: generate fstab output
  changed_when: false
  command: genfstab -U /mnt
  register: c

- name: update fstab file
  blockinfile: block={{ c.stdout }} dest=/mnt/etc/fstab

- name: uncomment locales
  lineinfile: backrefs=yes
              dest=/mnt/etc/locale.gen
              line=\1
              regexp="^#({{ locale }}.{{ charset }} {{ charset }})"
  register: lif

- name: generate locales
  command: locale-gen
  when: lif | changed

- name: set locale
  lineinfile: create=yes dest=/mnt/etc/locale.conf line=LANG={{ locale }}.{{ charset }}

- name: set timezone
  file: path=/mnt/etc/localtime src=/usr/share/zoneinfo/{{ timezone }} state=link

- name: create new initial ram disk
  command: creates=/mnt/boot/initramfs-linux.img arch-chroot /mnt mkinitcpio -p linux

- name: check root password
  changed_when: false
  register: s
  shell: arch-chroot /mnt passwd -S | cut -d ' ' -f 2

- name: set root password
  shell: printf "{{ password }}\n{{ password }}" | arch-chroot /mnt passwd
  when: s.stdout == "NP"

Remove `-p` due it is enabled by default
Remove `-p` due it is enabled by default
