The packer file looks like this:
{
"variables": {
"name": "packer",
"source_ami": "ami-0d527b8c289b4af7f",
"access_key": "",
"secret_key": "",
"region": "eu-central-1"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `access_key`}}",
"secret_key": "{{user `secret_key`}}",
"ami_name": "{{user `name`}}",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"instance_type": "t2.micro",
"communicator": "ssh",
"ssh_username": "ubuntu",
"run_tags": {
"Name": "reddit"
}
}
],
"provisioners": [
{
"type": "shell",
"script": "/home/ansibleclient/devops/scripts/reddit_scripts/bash/install_ruby.sh",
"execute_command": "sudo {{.Path}}"
},
{
"type": "shell",
"script": "/home/ansibleclient/devops/scripts/reddit_scripts/bash/install_mongodb.sh",
"execute_command": "sudo {{.Path}}"
}
]
}
Ruby installation file:
#!/bin/bash
set -e
# Update system
add-apt-repository ppa:awstools-dev/awstools
apt-get update
# Install Ruby
apt-get install -y ruby-full ruby-bundler build-essential
MondoDB installation file:
#!/bin/bash
# Mongodb
echo "y" | apt-get install mongodb
# Start MongoDB
systemctl start mongodb
# Add to autorun
systemctl enable mongodb
# Check status mongodb
systemctl status mongodb
When executing the "packer build" command, errors appear:
The first error appears 2 times, and I do not understand what it is connected with, it appears when using scripts.
==> amazon-ebs: debconf: unable to initialize frontend: Dialog
==> amazon-ebs: debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
==> amazon-ebs: debconf: falling back to frontend: Readline
==> amazon-ebs: debconf: unable to initialize frontend: Readline
==> amazon-ebs: debconf: (This frontend requires a controlling tty.)
==> amazon-ebs: debconf: falling back to frontend: Teletype
==> amazon-ebs: dpkg-preconfigure: unable to re-open stdin:
The second error appears when implementing the script "install_mongodb.sh "
==> amazon-ebs: Synchronizing state of mongodb.service with SysV service script with /lib/systemd/systemd-sysv-install.
==> amazon-ebs: Executing: /lib/systemd/systemd-sysv-install enable mongodb