packer.json 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {
  2. "variables": {
  3. "user": "vagrant",
  4. "password": "vagrant"
  5. },
  6. "provisioners": [
  7. {
  8. "type": "shell",
  9. "inline": [
  10. "sudo apt-get update -qq",
  11. "sudo apt-get install -y git-core python-pip python-apt libffi-dev libssl-dev build-essential python-virtualenv python-setuptools",
  12. "mkdir -p /tmp/mastodon",
  13. "git clone https://github.com/tootsuite/mastodon-ansible /tmp/mastodon/ansible"
  14. ]
  15. },
  16. { "type": "shell",
  17. "inline": [
  18. "install -m0700 -o {{user `user`}} -g {{user `user`}} -d /home/{{user `user`}}/.ssh",
  19. "curl -SsL https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -o /home/{{user `user`}}/.ssh/authorized_keys"
  20. ]
  21. },
  22. { "type": "shell",
  23. "execute_command": "{{ .Vars }} sudo -E -S sh '{{ .Path }}'",
  24. "inline": [
  25. "mount -o loop ${HOME}/VBoxGuestAdditions.iso /mnt",
  26. "/mnt/VBoxLinuxAdditions.run install",
  27. "umount /mnt",
  28. "rm ${HOME}/VBoxGuestAdditions.iso"
  29. ]
  30. },
  31. {
  32. "type": "shell",
  33. "inline": [
  34. "virtualenv venv",
  35. ". venv/bin/activate",
  36. "pip install --upgrade ansible==2.2.2.0"
  37. ]
  38. },
  39. {
  40. "type": "file",
  41. "source": "config/ansible.hosts",
  42. "destination": "/tmp/mastodon/ansible.hosts"
  43. },
  44. {
  45. "type": "shell",
  46. "environment_vars": ["ANSIBLE_REMOTE_TEMP=\"/tmp/mastodon/.ansible-tmp\"", "ANSIBLE_SSH_PIPELINING=True" ],
  47. "inline": [
  48. ". venv/bin/activate",
  49. "ansible-playbook -i /tmp/mastodon/ansible.hosts -v -b --extra-vars mastodon_db_password=CHANGEME /tmp/mastodon/ansible/bare/playbook.yml"
  50. ]
  51. },
  52. {
  53. "type": "shell",
  54. "execute_command": "{{ .Vars }} sudo -E -S sh '{{ .Path }}'",
  55. "scripts": ["scripts/clean.sh", "scripts/minimize.sh"]
  56. }
  57. ],
  58. "builders": [
  59. {
  60. "type": "virtualbox-iso",
  61. "boot_command": [
  62. "<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
  63. "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
  64. "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
  65. "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
  66. "/install/vmlinuz ",
  67. " auto ",
  68. " console-setup/ask_detect=false ",
  69. " console-setup/layoutcode=us ",
  70. " console-setup/modelcode=pc105 ",
  71. " debconf/frontend=noninteractive ",
  72. " debian-installer=en_US.UTF-8 ",
  73. " fb=false ",
  74. " initrd=/install/initrd.gz ",
  75. " kbd-chooser/method=us ",
  76. " keyboard-configuration/layout=USA ",
  77. " keyboard-configuration/variant=USA ",
  78. " locale=en_US.UTF-8 ",
  79. " netcfg/get_domain=vm ",
  80. " netcfg/get_hostname=vagrant ",
  81. " grub-installer/bootdev=/dev/sda ",
  82. " noapic ",
  83. " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
  84. " -- <wait>",
  85. "<enter><wait>"
  86. ],
  87. "boot_wait": "10s",
  88. "disk_size": 10000,
  89. "guest_os_type": "Ubuntu_64",
  90. "headless": true,
  91. "http_directory": "preseeds",
  92. "iso_urls": "http://releases.ubuntu.com/16.04/ubuntu-16.04.4-server-amd64.iso",
  93. "iso_checksum_type": "sha256",
  94. "iso_checksum": "0a03608988cfd2e50567990dc8be96fb3c501e198e2e6efcb846d89efc7b89f2",
  95. "ssh_username": "{{user `user`}}",
  96. "ssh_password": "{{user `password`}}",
  97. "ssh_wait_timeout": "20m",
  98. "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
  99. "vm_name": "packer-ubuntu-16.04-amd64",
  100. "vboxmanage": [
  101. [
  102. "modifyvm",
  103. "{{.Name}}",
  104. "--memory",
  105. "1024"
  106. ],
  107. [
  108. "modifyvm",
  109. "{{.Name}}",
  110. "--cpus",
  111. "1"
  112. ]
  113. ]
  114. }
  115. ],
  116. "post-processors": [
  117. [
  118. {
  119. "output": "builds/{{.Provider}}-mastodon-ubuntu1604.box",
  120. "type": "vagrant"
  121. },
  122. {
  123. "type": "vagrant-cloud",
  124. "box_tag": "mastodon/ubuntu-xenial64",
  125. "version": "0.5.{{timestamp}}"
  126. }
  127. ]
  128. ],
  129. "push": {
  130. "name": "mastodon/ubuntu-xenial64",
  131. "vcs": true
  132. }
  133. }