---
- name: Setup keyboard
  become: yes
  copy:
    src: etc/X11/xorg.conf.d/20-keyboard.conf
    dest: /etc/X11/xorg.conf.d/20-keyboard.conf
    owner: root
    group: root
    mode: 0644
  tags:
    - xorg
    
- name: Install Intel video driver
  become: yes
  pacman:
    name: "xf86-video-intel"
    update_cache: yes
    state: latest
  when:
    - ansible_local.hardware.vga_vendor == "Intel Corporation"
  tags:
    - xorg

- name: Install nvidia video driver
  become: yes
  pacman:
    name: "{{ item }}"
    update_cache: yes
    state: latest
  with_items:
    - "nvidia"
    - "libvdpau"
    - "nvidia-settings"
    - "nvidia-utils"
  when:
    - ansible_local.hardware.vga_vendor == "NVIDIA Corporation"
  tags:
    - xorg

---
- name: Setup keyboard
  become: yes
  copy:
    src: etc/X11/xorg.conf.d/20-keyboard.conf
    dest: /etc/X11/xorg.conf.d/20-keyboard.conf
    owner: root
    group: root
    mode: 0644
  tags:
    - xorg

- name: Install Intel video driver
  become: yes
  pacman:
    name: "xf86-video-intel"
    update_cache: yes
    state: latest
  when:
    - ansible_local.hardware.vga_vendor == "Intel Corporation"
  tags:
    - xorg

- name: Install nvidia video driver
  become: yes
  pacman:
    name: "{{ item }}"
    update_cache: yes
    state: latest
  with_items:
    - "nvidia-dkms"
    - "libvdpau"
    - "nvidia-settings"
    - "nvidia-utils"
  when:
    - ansible_local.hardware.vga_vendor == "NVIDIA Corporation"
  tags:
    - xorg

Use -dkms variant of nvidia module
Use -dkms variant of nvidia module
