forked from mavrick202/terraformsingleinstance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathansible-sudo-user-packer.json
More file actions
38 lines (38 loc) · 1.35 KB
/
ansible-sudo-user-packer.json
File metadata and controls
38 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
"_comment" : "AMI Image With Docker & Nginx",
"variables": {
"region": "",
"source_ami":"",
"instance_type":"",
"vpc_id": "",
"subnet_id": ""
},
"_comment1" : "packer build -var \"aws_secret_key=foo\" packer.json",
"_comment2" : "packer build -var-file packer-vars.json packer.json",
"builders": [{
"type": "amazon-ebs",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"instance_type": "{{user `instance_type`}}",
"ssh_username": "ubuntu",
"ami_name": "DevOpsClass-B26-ansible2-{{isotime | clean_resource_name}}",
"vpc_id": "{{user `vpc_id`}}",
"subnet_id": "{{user `subnet_id`}}",
"tags": {
"Name": "DevOpsClass-B26-ansible2-{{isotime | clean_resource_name}}"
}
}],
"provisioners": [{
"type": "shell",
"inline": [
"sudo useradd -m ansibleadmin --shell /bin/bash",
"sudo mkdir -p /home/ansibleadmin/.ssh",
"sudo chown -R ansibleadmin /home/ansibleadmin/",
"sudo touch /home/ansibleadmin/.ssh/authorized_keys",
"sudo usermod -aG sudo ansibleadmin",
"echo 'ansibleadmin ALL=(ALL) NOPASSWD: ALL' | sudo tee -a /etc/sudoers",
"echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDO6327tes.......' | sudo tee /home/ansibleadmin/.ssh/authorized_keys"
]
}
]
}