HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- 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

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    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 via Google

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully