This Ansible playbook is designed to partition, format, and mount block devices on EC2 instances. It can be used standalone or in conjunction with Terraform code (ec2-create-attach
) that creates EC2 instances, volumes, and attaches volumes to instances.
- Clone the
ec2-create-attach
repository into your local environment. - Follow the instructions in the
README.md
file of theec2-create-attach
repository to provision your infrastructure using Terraform. - Use the inventory file generated by Terraform as input for the Ansible playbook.
If you're not using Terraform to provision EC2 instances and volumes, you can still use this playbook by adjusting it for your environment.
- Modify the playbook (
your_playbook.yaml
) to match your requirements, such as specifying different block devices or hostnames. - Ensure that the block devices and hostnames are properly defined in your Ansible inventory file.
- Parted version 1.8.3 and above. Parted is part of the
community.general
collection. To install it, use:ansible-galaxy collection install community.general
. ansible.posix
collection. To install it, run:ansible-galaxy collection install ansible.posix
.
- The playbook assumes the use of Amazon Linux instances. If you're using a different Linux distribution, you may need to adjust the tasks accordingly.
- Make sure to replace placeholder values with the appropriate values for your environment.
- The
block_devices
variable in the inventory file should contain the last letter of each block device name as obtained from the Terraform code to ensure dynamic partitioning. - We welcome your feedback and encourage you to report any issues or suggestions for improvement.