#
# This role sets up serial console on ttyS1
#
- name: check for grub serial setup
  command: grub2-editenv list
  register: serial
  check_mode: no
  changed_when: '1 != 1'
  failed_when: '1 != 1'
  tags:
  - serial-console

- name: set grub to use serial console
  command: /sbin/grubby --update-kernel=ALL --args="console=tty0 console=ttyS0,115200 console=ttyS1,115200"
  when: serial is defined and serial.stdout.find("console=tty0 console=ttyS0,115200 console=ttyS1,115200") == -1
  failed_when: '1 != 1'
  tags:
  - serial-console

- name: enable and start getty on both serial ports
  systemd:
    name: serial-getty@ttyS0
    state: started
    enabled: true
  tags:
  - serial-console

- name: enable and start getty on both serial ports
  systemd:
    name: serial-getty@ttyS1
    state: started
    enabled: true
  tags:
  - serial-console
