--- title: 姫路IT系勉強会 2018.08 Vagratn/Ansibleハンズオン langs: ja-jp GA: UA-39104128-6 tags: histudy --- # 姫路IT系勉強会 2018.08 * 開催日:2018/08/18 * 司会:wateさん * 参加者数:参加者: 9 名 / 学生: 0 名 * hackMd: https://hackmd.io/BZ0tL__yRv6aCq_j8enpyA * connpass: https://histudy.connpass.com/event/97126/ * ハッシュタグ:#histudy * [#histudy - Twitter検索](https://twitter.com/search?q=%23histudy&src=typd) ## 自己紹介 ## ハンズオン 適宜、メモを書いていきましょう。 ### Vagrantとは * 仮想環境/クラウド環境を統一的なインターフェイスでコントロールする開発支援ツール * 開発環境を簡単に作れるぜ! VirtualBoxとか経由して。 * サーバー構築のスキルがなくてもコマンドでいける * ベースになる*Box* = イメージファイルがまず必要 * 今回は[histudy/stretch](https://app.vagrantup.com/histudy/boxes/stretch) * Vagrant コマンド(https://www.vagrantup.com/docs/cli/) - vagrant box - vagrant up - vagrant halt - vagrant destroy * vagrant の *Provision* で仮想化の起動後の設定やらを記述する * `vagrant up` でProvisionされる時にAnsibleも走る。 * 今回は、[ansible_local](https://www.vagrantup.com/docs/provisioning/ansible_local.html)を使う * ホストOSの影響を排除するため、shell provision -> ansible インストール * 使用するリポジトリ(https://github.com/histudy/vagrant-redmine) * extra_vars.ymlを使った場合、初期構築時のRedmineのログイン情報と異なっている(user: admin, password: password) ### 手順 ※ 会場のネットワーク環境の混雑解消のため vagrantのベースboxを事前に取得しておいた。 $ vagrant box add histudy/stretch $ git clone https://github.com/histudy/vagrant-redmine.git $ cp -a extra_vars_example.yml extra_vars.yml extra_vars.yml 内の、Redmine プラグインインストール部分のうち、「agile」「checklists」をコメントアウト(565行以降) diff -u extra_vars_example.yml extra_vars.yml --- extra_vars_example.yml 2018-08-17 00:23:30.000000000 +0900 +++ extra_vars.yml 2018-08-18 14:29:09.000000000 +0900 @@ -562,11 +562,11 @@ # チケットの登録日を日付で表示する機能を追加 # ref: https://github.com/suer/redmine_absolute_dates repo: "https://github.com/suer/redmine_absolute_dates.git" - - name: agile + #- name: agile # カンバン機能を追加 # ref: https://www.redmineup.com/pages/ja/plugins/agile - file: /vagrant/plugins/redmine_agile-1_4_6-light.zip - - name: checklists + #file: /vagrant/plugins/redmine_agile-1_4_6-light.zip + #- name: checklists # チケットにチェックリストを追加 # ref: https://www.redmineup.com/pages/ja/plugins/checklists - file: /vagrant/plugins/redmine_checklists-3_1_11-light.zip + #file: /vagrant/plugins/redmine_checklists-3_1_11-light.zip yamlを書き換える前に仮想マシンを起動している場合、仮想マシンを削除し再起動しておく $ vagrant destroy 仮想マシンを起動する $ vagrant up http://localhost:8080/ にアクセス! アカウント情報は extra_var.yml の redmine_admin のセクションを参照してください。 --- ## トラブルシューティング ### macOSで VirtualBox のインストールに失敗する インストールに失敗したあと、OSを再起動し、システム環境設定 -> セキュリティ & プライバシー で Oracle からのインストールを許可し、再度 VirtualBox をインストールする。 ### vagrant upするとSSHの接続でリトライを繰り返して止まる 「Warning: Remote connection disconnect. Retrying...」を繰り返してSSHで止まってしまいAnsibleが実行されない ``` ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Remote connection disconnect. Retrying... default: Warning: Remote connection disconnect. Retrying... ``` 環境変数を設定してからvagrant upを実行するとよい。 $ export SSH_AUTH_SOCK="" * Vagrant up fails with Warning: Remote connection disconnect. Retrying... · Issue #9834 · hashicorp/vagrant: <https://github.com/hashicorp/vagrant/issues/9834> ### 「SSH auth method: private key」で止まる VirtualBoxのネットワーク接続を見て、「ケーブル接続」のチェックが外れていれば、チェックを入れて `vagrant reload` する。 * "vagrant up"したら"SSH auth method: private key"で止まった話: <https://qiita.com/sasurai_usagi3/items/2ba572013b16f2703f6a> ### [GalliumOS](https://galliumos.org/)の特殊な環境です GalliumOS:ChromeBookに最適化したという謳い文句のLinuxフレーバー、Xubuntuベース * Ansibleの設定を書いたansible_extra_vars Ymlファイルをロードしない * Ruby処理系? 2.3ー> 2.4にアップしたが同じくダメ * もしかしたらUbuntuはパッケージのVirtualBox/Vagrantを使うべきかも * VirtualBoxは最新のをOracleからダウンロードしていたのを削除、`apg-get`で入れ直した * Yamlのロードはコメントアウト ``` #extra_var_file = File.expand_path(File.join(File.dirname(__FILE__), 'extra_vars.yml')) #if File.exists?(extra_var_file) # ansible_extra_vars = YAML.load_file(extra_var_file) #end ``` * Ansibleのエラー ``` ansible local provisioner: The following settings shouldn't exist: become, compatibility_mode, config_file ``` メッセージに従ってVagrantファイルを更にコメントアウト ``` ==> default: Configuring and enabling network interfaces... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! ``` ネットワークのエラー IPアドレスの指定をコメントアウト ``` PLAY [Deploy Redmine] ******* TASK [Gathering Facts] ****** ok: [default] TASK [mariadb : install ufw package] *** fatal: [default]: FAILED! => ``` ここまでは辿り着きました。 ### redmine bundle のインストールに失敗 redmineのbundleのインストールに失敗した場合、以下のようにインストールをし直す HOST$ vagrant ssh VM$ cd /opt/redmine/ VM$ sudo -u redmine bundle install VM$ exit HOST$ vagrant provision http://localhost:8080/ に再アクセス! ### redemine で maria dbのmigrateに失敗 redmineのmigrateに失敗した場合、以下のようにmigrateし直す HOST$ vagrant ssh VM$ cd /opt/redmine/ VM$ sudo -u redmine rake redmine:plugins:migrate VM$ exit HOST$ vagrant provision http://localhost:8080/ にアクセス! ## Ansibleのメリット アプリ開発も、インフラのことが分からないと 「何か分からんけど動かん」 で止まってしまう。 * サーバー構築手順がymlファイルで残る * 手動で構築してしまうと、設定内容が分からない * そのまま再利用ができる * 似たようなサーバを作る時は流用できる * 「構築手順書」としてマニュアル残すより確実&便利 * Ansibleの練習には、自由に使えるサーバーが必要 * 仮想化サーバなら手元で作って壊して出来る * Vagrant + VirtualBoxだと手元で簡単にできる #### vs Docker * 用途とか考えて選ぶ * アプリケーションのテスト、チューニング、ビルドetc. * アプリのテストにはDockerの方が楽かも * その分、自由度がない、本番環境との違い * 基本Rootユーザーでパーミッションがない * 1コンテナ1プロセス * 決まりきったモノを動かす場合は、Dockerが楽 ### 質問とか * vagrantでhostsを書き換えてくれるプラグイン([vagrant-hostsupdater](https://github.com/cogitatio/vagrant-hostsupdater))は書き戻しもしてくれますか? * 戻してくれるけど、vagrantが死んだ場合など戻さないので確認の必要アリ * ansible と vagrant がセットになっているのはなぜ? * ansible はサーバー構築ツール。使い方を練習するには、vagrant で手元のパソコンでやるのが安くすむからではないか。 * 一台のサーバーに、複数のユーザーがある。各ユーザーのホームにファイルを配布するには、各ユーザーで接続するか、ルート権限で配布して所有権を修正するか、どちらが良いか。 * どちらでも良いが、ルート権限で処理をループさせるのも良いかも。 * gitlabのプロジェクト管理はどうか? * gitlabのプロジェクト管理機能を使っている方がいなかった * Redmineの使いドコロ * 開発者、コードを書く人が複数いる場合の状況把握 * 機能としては顧客対応、カスタマーサービスにも使える * RedmineベースでInvoice作成に対応しているサービスも、小売・物流向け * ステータスが細かい、ほぼ無限に増やせる(Backlogは4つ) * ロール別の権限設定もできる * 「顧客」ロールは「チェック済み」「差し戻し」 のみにする等 * ここはイマイチ * 取っつきにくい見た目 * テーマ変えられるけど少ない * ワークフローを自分で組まなくてはいけない * いろいろな人に優しくするのは大変 * CSVで書き出して、Excel ---- ## 次回予定! * 加古川IT系インフラ勉強会 2018年9月 * 2018/09/08 * 姫路IT系勉強会 2018年9月 * 2018/09/15
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up