1 Respuesta
- Más nuevo
- Más votos
- Más comentarios
2
Hi!
What you described can be achieved with user-data, it might be tricky and a not so stylish script, but possible.
Now, If you don't mind I would like to recommend the Use of Packer https://www.packer.io/
Why? Well with packer you can build what is often called Golden AMI, such AMI can be pushed and used when you deploy your instance. Now setting up the configuration management can be achieved using what Packers call "Provisioners", below you will see an example of each provisioner that might be interesting for you, and if you really want a neat way to build the AMI with the required configuration, you can use Ansible as provisioner and define your tasks in Ansible Playbooks or Roles.
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"region": "us-east-1"
},
"builders": [
{
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"type": "amazon-ebs",
"profile": "default",
"region": "{{user `region`}}",
"instance_type": "t2.micro",
"ssh_username": "centos",
"source_ami" : "ami-0affd4508a5d2481b",
"ami_name": "centos-aws-demo-{{timestamp}}",
"ami_description":"CentOS Linux 7 x86_64 HVM EBS ENA 2002_01 with docker",
"run_tags" : {
"Name" : "packer-builder-docker",
"Tool" : "Packer",
"Author" : "DavidCaballero"
},
"tags": {
"Name": "centos-aws-demo"
}
}
],
"provisioners": [
{
"type": "file",
"source": "./welcome.txt",
"destination": "/home/centos/"
},
{
"type": "shell",
"inline": ["ls -al /home/centos", "cat /home/centos/welcome.txt"]
},
{
"type": "shell",
"script": "./docker_install.sh"
},
{
"type": "ansible",
"playbook_file": "./playbooks/hostname.yml"
}
]
}
respondido hace un año
Contenido relevante
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace un año
- OFICIAL DE AWSActualizada hace un año
This is great. I'll have to have a look at Packer/Ansible. I've been trying to learn Terraform so this should prove to be helpful.
Thanks!