{"action":"created","comment":{"url":"https://api.github.com/repos/Temox/infra/pulls/comments/142650040","pull_request_review_id":67039264,"id":142650040,"diff_hunk":"@@ -1,13 +1,162 @@\n-# infra\n-## Infrastructure repository\n-devops homeworks\n+# Infra - Инфраструктурный репозиторий\n+## DevOps - практика\n+### Управление облачной инфраструкурой с помощью утилиты **gcloud**\n+\n+Создание ВМ с применением внешних startup скриптов.\n+  ./startup.sh -скрипт описывающий установку mongodb, ruby, bundler и деплой [web-приложения](https://github.com/Artemmkin/reddit.git).\n \n-Create VM and apply startup script\n ```\n gcloud compute instances create --boot-disk-size=10GB --image=ubuntu-1604-xenial-v20170815a --image-project=ubuntu-os-cloud --machine-type=g1-small --tags puma-server --restart-on-failure --zone=europe-west1-b reddit-app --metadata-from-file startup-script=/home/temox/infra/startup.sh\n ```\n \n-Add firewall rule\n+Добавление firewall-правил.\n+Устанавливаемое приложение работает на порту tcp:9292. Создаваемое правило позволяет открыть доступ на уровне VPC.\n ```\n gcloud compute firewall-rules create default-puma-server --source-ranges=0.0.0.0/0 --allow=tcp:9292 --target-tags=puma-server\n ```\n+\n+### Packer. Сборка образов.\n+*Packer* - ПО позволяющее создавать кастомизированые образы ОС на основе имеющихся дефолтных, предоставляемых провайдерами облачных систем.\n+\n+_infra/packer/by_scripts/ubuntu16.json_ - шаблон для создания ВМ в облаке GCP.\n+\n+В данном примере используется _builder_ _goolecompute_ для работы с API GCP.\n+\n+Для кастомизации образа, установки необходимого ПО и копирования приложения, используются _provisioners_, для запуска .sh скриптов, _shell_. \n+\n+В качестве .sh скриптов используются файлы:\n+```\n+    infra/packer/scripts/\n+                 ├── install_mongodb.sh - устанвка _MongoDb_\n+                 └── install_ruby.sh    - установка _Ruby_ и _Bundler_\n+```\n+\n+В качестве переменных _variables_ указываеются параметры определяющие проект в GCP _project_id_, дефолтный образ _source_image_ и тип создаваемого инстанса _machine_type_.\n+\n+Результатом запуска _packer_ с данным шаблоном, является ВМ подготовленная к диплою приложения Ruby-приложения:\n+```\n+packer build -var 'project_id=*ID-проекта_в_облаке*' -var 'source_image=*Имя_образа*' packer/by_scripts/ubuntu16.json\n+```\n+\n+### Terraform. Основы IaC.\n+*Terraform* - ПО позволяющее описать требуемуе состояние инфраструктуры, с момента создания виртуального сервера и добавления правил firewall, до деплоя самого приложения.\n+\n+*./terraform* - описание создания prod и stage инфрастуктуры. Включает в себя создание серверов БД и серверов приложений.\n+\n+```\n+terraform/\n+── files\n+   ├── deploy.sh                 - shell-скрпит деплоя приложения\n+   └── puma.service              - unit-файл для запуска приложения\n+```\n+\n+Создание сервера-приложения, сервера-БД и настройка облачного firewall'а описаны в виде модулей:\n+```\n+── modules\n+   ├── app  - создание сервера приложений\n+   ├── db   - создание сервера БД\n+   └── vpc  - настройка VPC\n+```\n+Каждый модуль описан тремя файлами:\n+\n+* *mian.tf*       - создание виртуальной машины, правил облачного файерволла, добавление ssh-ключа для пользователя, добавление внешенго ip-адреса\n+* *variables.tf*  - описание используемых в модуле переменных\n+* *outputs.tf*    - описание выводимых переменных после выполнения развертывания. Доступны при выполнении _terraform show_\n+\n+Создание _prod_ и _stage_ стендов:\n+```\n+── terraform\n+   ├── prod\n+   └── stage\n+```\n+Описание стендов\n+* *main.tf*       - содержит кастомизированое описание вызова модулей app-сервера, db-сервера и vpc\n+* *outputs.tf*    - описание выводимых переменных после выполнения развертывания. Доступны при выполнении _terraform show_\n+* *variables.tf*  - описание используемых переменных для сетнда.\n+\n+\n+### Ansible. Управление конфигурацией.\n+\n+Ansible использует конфигурционный файл в соответсвующей дирректории:\n+```\n+── ansible\n+   └── ansible.cfg\n+```\n+В данном примере указаны лишь основные параметры:\n+```\n+  [defaults]\n+  hostfile = ./environments/stage/hosts\n+  remote_user = appuser\n+  private_key_file = ~/.ssh/appuser\n+  host_key_checking = False\n+```\n+\n+Выполнены различные варианты подготовки серверной инфраструктуры\n+\n+* Подготовка образов систем packer'ом, с предварительной настройкой:\n+  _packer_reddit_app.yml_\n+  _packer_reddit_db.yml_\n+* Общий _playbook_ для подготовки серверов и выполнения деполя, с использованием тегов:\n+  _reddit_app_one_play.yml_\n+* Общий _playbook_ для подготовки серверов и выполнения деполя, с использованием нескольких task'ов:\n+  _reddit_app_multiple_plays.yml_\n+* Создание роли:\n+```\n+── ansible\n+    ├── app.yml\n+    ├── db.yml\n+    ├── roles\n+    │   ├── app\n+    │   └── db\n+    └── site.yml\n+ ```\n+   и использование _packer_ для подготовки образов на основе ролей:\n+   ```\n+    ├── packer_app.yml\n+    ├── packer_db.yml\n+   ```\n+Для создания stag и prod стендов используется _environment_, где описано создание каждого из стендов и определены соответвующие переменные, на основе групп хостов:","path":"README.md","position":123,"original_position":123,"commit_id":"7cff2f7a96b76bdcd9b4804de08ee2e6abfe5a58","original_commit_id":"7cff2f7a96b76bdcd9b4804de08ee2e6abfe5a58","user":{"login":"Artemmkin","id":17411348,"avatar_url":"https://avatars1.githubusercontent.com/u/17411348?v=4","gravatar_id":"","url":"https://api.github.com/users/Artemmkin","html_url":"https://github.com/Artemmkin","followers_url":"https://api.github.com/users/Artemmkin/followers","following_url":"https://api.github.com/users/Artemmkin/following{/other_user}","gists_url":"https://api.github.com/users/Artemmkin/gists{/gist_id}","starred_url":"https://api.github.com/users/Artemmkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Artemmkin/subscriptions","organizations_url":"https://api.github.com/users/Artemmkin/orgs","repos_url":"https://api.github.com/users/Artemmkin/repos","events_url":"https://api.github.com/users/Artemmkin/events{/privacy}","received_events_url":"https://api.github.com/users/Artemmkin/received_events","type":"User","site_admin":false},"body":"наверное, сказать `для управления конфигурацией`, создаем мы их в тераформе","created_at":"2017-10-04T11:59:22Z","updated_at":"2017-10-04T11:59:22Z","html_url":"https://github.com/Temox/infra/pull/9#discussion_r142650040","pull_request_url":"https://api.github.com/repos/Temox/infra/pulls/9","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Temox/infra/pulls/comments/142650040"},"html":{"href":"https://github.com/Temox/infra/pull/9#discussion_r142650040"},"pull_request":{"href":"https://api.github.com/repos/Temox/infra/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/Temox/infra/pulls/9","id":144397690,"html_url":"https://github.com/Temox/infra/pull/9","diff_url":"https://github.com/Temox/infra/pull/9.diff","patch_url":"https://github.com/Temox/infra/pull/9.patch","issue_url":"https://api.github.com/repos/Temox/infra/issues/9","number":9,"state":"open","locked":false,"title":"Homework 13. Developing and testing of Ansible playbooks and roles.","user":{"login":"Temox","id":8046620,"avatar_url":"https://avatars0.githubusercontent.com/u/8046620?v=4","gravatar_id":"","url":"https://api.github.com/users/Temox","html_url":"https://github.com/Temox","followers_url":"https://api.github.com/users/Temox/followers","following_url":"https://api.github.com/users/Temox/following{/other_user}","gists_url":"https://api.github.com/users/Temox/gists{/gist_id}","starred_url":"https://api.github.com/users/Temox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Temox/subscriptions","organizations_url":"https://api.github.com/users/Temox/orgs","repos_url":"https://api.github.com/users/Temox/repos","events_url":"https://api.github.com/users/Temox/events{/privacy}","received_events_url":"https://api.github.com/users/Temox/received_events","type":"User","site_admin":false},"body":"Homework 13. Developing and testing of Ansible playbooks and roles","created_at":"2017-10-03T11:27:13Z","updated_at":"2017-10-04T11:59:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[{"login":"Nklya","id":26086394,"avatar_url":"https://avatars2.githubusercontent.com/u/26086394?v=4","gravatar_id":"","url":"https://api.github.com/users/Nklya","html_url":"https://github.com/Nklya","followers_url":"https://api.github.com/users/Nklya/followers","following_url":"https://api.github.com/users/Nklya/following{/other_user}","gists_url":"https://api.github.com/users/Nklya/gists{/gist_id}","starred_url":"https://api.github.com/users/Nklya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nklya/subscriptions","organizations_url":"https://api.github.com/users/Nklya/orgs","repos_url":"https://api.github.com/users/Nklya/repos","events_url":"https://api.github.com/users/Nklya/events{/privacy}","received_events_url":"https://api.github.com/users/Nklya/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Temox/infra/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Temox/infra/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Temox/infra/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Temox/infra/issues/9/comments","statuses_url":"https://api.github.com/repos/Temox/infra/statuses/7cff2f7a96b76bdcd9b4804de08ee2e6abfe5a58","head":{"label":"Temox:ansible-4","ref":"ansible-4","sha":"7cff2f7a96b76bdcd9b4804de08ee2e6abfe5a58","user":{"login":"Temox","id":8046620,"avatar_url":"https://avatars0.githubusercontent.com/u/8046620?v=4","gravatar_id":"","url":"https://api.github.com/users/Temox","html_url":"https://github.com/Temox","followers_url":"https://api.github.com/users/Temox/followers","following_url":"https://api.github.com/users/Temox/following{/other_user}","gists_url":"https://api.github.com/users/Temox/gists{/gist_id}","starred_url":"https://api.github.com/users/Temox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Temox/subscriptions","organizations_url":"https://api.github.com/users/Temox/orgs","repos_url":"https://api.github.com/users/Temox/repos","events_url":"https://api.github.com/users/Temox/events{/privacy}","received_events_url":"https://api.github.com/users/Temox/received_events","type":"User","site_admin":false},"repo":{"id":102712574,"name":"infra","full_name":"Temox/infra","owner":{"login":"Temox","id":8046620,"avatar_url":"https://avatars0.githubusercontent.com/u/8046620?v=4","gravatar_id":"","url":"https://api.github.com/users/Temox","html_url":"https://github.com/Temox","followers_url":"https://api.github.com/users/Temox/followers","following_url":"https://api.github.com/users/Temox/following{/other_user}","gists_url":"https://api.github.com/users/Temox/gists{/gist_id}","starred_url":"https://api.github.com/users/Temox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Temox/subscriptions","organizations_url":"https://api.github.com/users/Temox/orgs","repos_url":"https://api.github.com/users/Temox/repos","events_url":"https://api.github.com/users/Temox/events{/privacy}","received_events_url":"https://api.github.com/users/Temox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Temox/infra","description":"Devops practices","fork":false,"url":"https://api.github.com/repos/Temox/infra","forks_url":"https://api.github.com/repos/Temox/infra/forks","keys_url":"https://api.github.com/repos/Temox/infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Temox/infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Temox/infra/teams","hooks_url":"https://api.github.com/repos/Temox/infra/hooks","issue_events_url":"https://api.github.com/repos/Temox/infra/issues/events{/number}","events_url":"https://api.github.com/repos/Temox/infra/events","assignees_url":"https://api.github.com/repos/Temox/infra/assignees{/user}","branches_url":"https://api.github.com/repos/Temox/infra/branches{/branch}","tags_url":"https://api.github.com/repos/Temox/infra/tags","blobs_url":"https://api.github.com/repos/Temox/infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Temox/infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Temox/infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/Temox/infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Temox/infra/statuses/{sha}","languages_url":"https://api.github.com/repos/Temox/infra/languages","stargazers_url":"https://api.github.com/repos/Temox/infra/stargazers","contributors_url":"https://api.github.com/repos/Temox/infra/contributors","subscribers_url":"https://api.github.com/repos/Temox/infra/subscribers","subscription_url":"https://api.github.com/repos/Temox/infra/subscription","commits_url":"https://api.github.com/repos/Temox/infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/Temox/infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/Temox/infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/Temox/infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/Temox/infra/contents/{+path}","compare_url":"https://api.github.com/repos/Temox/infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Temox/infra/merges","archive_url":"https://api.github.com/repos/Temox/infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Temox/infra/downloads","issues_url":"https://api.github.com/repos/Temox/infra/issues{/number}","pulls_url":"https://api.github.com/repos/Temox/infra/pulls{/number}","milestones_url":"https://api.github.com/repos/Temox/infra/milestones{/number}","notifications_url":"https://api.github.com/repos/Temox/infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Temox/infra/labels{/name}","releases_url":"https://api.github.com/repos/Temox/infra/releases{/id}","deployments_url":"https://api.github.com/repos/Temox/infra/deployments","created_at":"2017-09-07T08:35:49Z","updated_at":"2017-10-03T09:28:27Z","pushed_at":"2017-10-03T11:27:13Z","git_url":"git://github.com/Temox/infra.git","ssh_url":"git@github.com:Temox/infra.git","clone_url":"https://github.com/Temox/infra.git","svn_url":"https://github.com/Temox/infra","homepage":"","size":122,"stargazers_count":0,"watchers_count":0,"language":"HCL","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Temox:master","ref":"master","sha":"882fe41e992034f8f3add946aeefccfb27666299","user":{"login":"Temox","id":8046620,"avatar_url":"https://avatars0.githubusercontent.com/u/8046620?v=4","gravatar_id":"","url":"https://api.github.com/users/Temox","html_url":"https://github.com/Temox","followers_url":"https://api.github.com/users/Temox/followers","following_url":"https://api.github.com/users/Temox/following{/other_user}","gists_url":"https://api.github.com/users/Temox/gists{/gist_id}","starred_url":"https://api.github.com/users/Temox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Temox/subscriptions","organizations_url":"https://api.github.com/users/Temox/orgs","repos_url":"https://api.github.com/users/Temox/repos","events_url":"https://api.github.com/users/Temox/events{/privacy}","received_events_url":"https://api.github.com/users/Temox/received_events","type":"User","site_admin":false},"repo":{"id":102712574,"name":"infra","full_name":"Temox/infra","owner":{"login":"Temox","id":8046620,"avatar_url":"https://avatars0.githubusercontent.com/u/8046620?v=4","gravatar_id":"","url":"https://api.github.com/users/Temox","html_url":"https://github.com/Temox","followers_url":"https://api.github.com/users/Temox/followers","following_url":"https://api.github.com/users/Temox/following{/other_user}","gists_url":"https://api.github.com/users/Temox/gists{/gist_id}","starred_url":"https://api.github.com/users/Temox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Temox/subscriptions","organizations_url":"https://api.github.com/users/Temox/orgs","repos_url":"https://api.github.com/users/Temox/repos","events_url":"https://api.github.com/users/Temox/events{/privacy}","received_events_url":"https://api.github.com/users/Temox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Temox/infra","description":"Devops practices","fork":false,"url":"https://api.github.com/repos/Temox/infra","forks_url":"https://api.github.com/repos/Temox/infra/forks","keys_url":"https://api.github.com/repos/Temox/infra/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Temox/infra/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Temox/infra/teams","hooks_url":"https://api.github.com/repos/Temox/infra/hooks","issue_events_url":"https://api.github.com/repos/Temox/infra/issues/events{/number}","events_url":"https://api.github.com/repos/Temox/infra/events","assignees_url":"https://api.github.com/repos/Temox/infra/assignees{/user}","branches_url":"https://api.github.com/repos/Temox/infra/branches{/branch}","tags_url":"https://api.github.com/repos/Temox/infra/tags","blobs_url":"https://api.github.com/repos/Temox/infra/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Temox/infra/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Temox/infra/git/refs{/sha}","trees_url":"https://api.github.com/repos/Temox/infra/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Temox/infra/statuses/{sha}","languages_url":"https://api.github.com/repos/Temox/infra/languages","stargazers_url":"https://api.github.com/repos/Temox/infra/stargazers","contributors_url":"https://api.github.com/repos/Temox/infra/contributors","subscribers_url":"https://api.github.com/repos/Temox/infra/subscribers","subscription_url":"https://api.github.com/repos/Temox/infra/subscription","commits_url":"https://api.github.com/repos/Temox/infra/commits{/sha}","git_commits_url":"https://api.github.com/repos/Temox/infra/git/commits{/sha}","comments_url":"https://api.github.com/repos/Temox/infra/comments{/number}","issue_comment_url":"https://api.github.com/repos/Temox/infra/issues/comments{/number}","contents_url":"https://api.github.com/repos/Temox/infra/contents/{+path}","compare_url":"https://api.github.com/repos/Temox/infra/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Temox/infra/merges","archive_url":"https://api.github.com/repos/Temox/infra/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Temox/infra/downloads","issues_url":"https://api.github.com/repos/Temox/infra/issues{/number}","pulls_url":"https://api.github.com/repos/Temox/infra/pulls{/number}","milestones_url":"https://api.github.com/repos/Temox/infra/milestones{/number}","notifications_url":"https://api.github.com/repos/Temox/infra/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Temox/infra/labels{/name}","releases_url":"https://api.github.com/repos/Temox/infra/releases{/id}","deployments_url":"https://api.github.com/repos/Temox/infra/deployments","created_at":"2017-09-07T08:35:49Z","updated_at":"2017-10-03T09:28:27Z","pushed_at":"2017-10-03T11:27:13Z","git_url":"git://github.com/Temox/infra.git","ssh_url":"git@github.com:Temox/infra.git","clone_url":"https://github.com/Temox/infra.git","svn_url":"https://github.com/Temox/infra","homepage":"","size":122,"stargazers_count":0,"watchers_count":0,"language":"HCL","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Temox/infra/pulls/9"},"html":{"href":"https://github.com/Temox/infra/pull/9"},"issue":{"href":"https://api.github.com/repos/Temox/infra/issues/9"},"comments":{"href":"https://api.github.com/repos/Temox/infra/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Temox/infra/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Temox/infra/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Temox/infra/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Temox/infra/statuses/7cff2f7a96b76bdcd9b4804de08ee2e6abfe5a58"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Artemmkin"}}