Skip to content

Instantly share code, notes, and snippets.

@kovkev
Last active October 8, 2019 14:18
Show Gist options
  • Save kovkev/92e19afb1152ef9cc0f75c3f1efa4ff3 to your computer and use it in GitHub Desktop.
Save kovkev/92e19afb1152ef9cc0f75c3f1efa4ff3 to your computer and use it in GitHub Desktop.
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp}}"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 80"
]
},
{
"type": "ansible",
"user": "root",
"playbook_file": "files/playbook_master.json",
"extra_arguments": [ "-vvvv", "--extra-vars", "--become-method=su"],
"ansible_env_vars": ["ANSIBLE_FORCE_COLOR=true", "USE_PERSISTENT_CONNECTIONS=false"]
}, {
"type": "shell",
"inline": [
"echo Thanks to https://alex.dzyoba.com/blog/packer-for-docker/ and make sure to use jsonnet to properly share the configuration."
]
}
]
}
{
become: true,
become_method: 'su',
hosts: 'all',
vars: {
kubernetes_allow_pods_on_master: true,
kubernetes_role: type,
},
{
name: "slow",
command: "/bin/sleep 90",
register: "some_job"
}
,
{
name: "check_who",
command: "whoami", # issue exists also when I use `shell: "whoami",`
become_user: "root",
# become_method: "su",
become: true,
# ansible_become: true,
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment