the following play work on t2 instances, the issue I am running into is when I try to run it against a t3 instance it fails.
it looks like the issue comes from the new instance types are using /dev/nvme0n1p1 for root and /nvme1n1 for the second drive. t2 vs (t3. m5 ,c5)
so is there a ec2 fact that I can filter on to set the var additional_disk:“{{platform}}”
any exampled that anone willing to share of how they are dealing with the change in device name for the new instance types.
additional_disk: /dev/xvdb
mountpoint: /mnt
-
name: check if {{ additional_disk }} exists
set_fact:
exist_device: True
when: ansible_devices[ “{{ additional_disk | basename }}” ] is defined -
name: check if {{ additional_disk }} in use
command: pvdisplay “{{ additional_disk }}”
register: result
ignore_errors: True -
name: format new volume
filesystem:
fstype: ext4
dev: “{{ additional_disk }}”
when: exist_device is defined and result|failed -
name: mount {{ additional_disk }} on {{ mountpoint }}
mount:
name: “{{ mountpoint }}”
src: “{{ additional_disk }}”
fstype: ext4
state: mounted
when: exist_device is defined and mountpoint is defined