Giter VIP home page Giter VIP logo

ansible-ec2's Introduction

EC2でラジオのリアルタイム録音をするためのansible

このansibleで毎日17:55から約3時間TBSラジオを録音するようになる。

事前準備

事前に以下を実施しておくこと。

ターゲットノード構築

初期設定対象のサーバ(ターゲットのーど)はEC2で作成し、sshでログインできる状態にしておく。

IPアドレスの書き換え

対象ホストのIPアドレス書き換える。

EC2はIPアドレスがその都度変わるため、ターゲットサーバのIPアドレスを書き換える

鍵のファイルパス書き換え

鍵ペアのファイルを以下で設定した場所に格納する。

下の例だと、/etc/ansible/pemfile/radio.pem

ansible_ssh_private_key_file=/etc/ansible/pemfile/radio.pem

playbook概要

以下のようなことを実施する。

  • パッケージの最新化
  • git、dockerのインストール
  • タイムゾーンの変更
  • dockerファイルのダウンドーロ
  • docker build
  • cron設定

環境

動作確認をした環境は以下。

OS:CentOS 7.4

ansibleバージョン

$ ansible --version
ansible 2.10.9
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

使い方

コマンド

以下のコマンドで動く。

ansible-playbook -i hosts site.yml

構文チェック(テスト)

PlaybookがYAMLとして正しく解釈できるか、存在しないモジュールを使用していないかは、以下のように--syntax-checkをつけて実行する。

ansible-playbook -i hosts site.yml --syntax-check

ansible-ec2's People

Contributors

yamadatt avatar

Watchers

 avatar

ansible-ec2's Issues

ansilbe-lintで出力したワーニングを直す

以下のワーニングが出力されているので解消したい。

command-instead-of-shell: Use shell only when shell functionality is required.
roles/system/tasks/main.yml:2 Task/Handler: check locale

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:2 Task/Handler: check locale

yaml: truthy value should be one of [false, true] (truthy)
roles/system/tasks/main.yml:5

command-instead-of-shell: Use shell only when shell functionality is required.
roles/system/tasks/main.yml:9 Task/Handler: set locale

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:9 Task/Handler: set locale

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:19 Task/Handler: yum updade

package-latest: Package installs should not use latest.
roles/system/tasks/main.yml:19 Task/Handler: yum updade

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:24 Task/Handler: yum install

var-spacing: Variables should have spaces before and after: { var_name }.
roles/system/tasks/main.yml:24 Task/Handler: yum install

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:33 Task/Handler: yum install docker-ce

package-latest: Package installs should not use latest.
roles/system/tasks/main.yml:33 Task/Handler: yum install docker-ce

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:39 Task/Handler: start & enable docker service

yaml: truthy value should be one of [false, true] (truthy)
roles/system/tasks/main.yml:43

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:46 Task/Handler: docker-compose1.29.2のインストール(バージョンは固定している)

yaml: truthy value should be one of [false, true] (truthy)
roles/system/tasks/main.yml:51

git-latest: Git checkouts must contain explicit version.
roles/system/tasks/main.yml:54 Task/Handler: git clone

command-instead-of-shell: Use shell only when shell functionality is required.
roles/system/tasks/main.yml:62 Task/Handler: docker build docker_rec_radiko

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:62 Task/Handler: docker build docker_rec_radiko

no-changed-when: Commands should not change things if nothing needs doing.
roles/system/tasks/main.yml:62 Task/Handler: docker build docker_rec_radiko

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:67 Task/Handler: debug var=result_shell

unnamed-task: All tasks should be named.
roles/system/tasks/main.yml:67 Task/Handler: debug var=result_shell

fqcn-builtins: Use FQCN for builtin actions.
roles/system/tasks/main.yml:71 Task/Handler: cron setting

You can skip specific rules or tags by adding them to your configuration file:

.config/ansible-lint.yml

warn_list: # or 'skip_list' to silence them completely

  • command-instead-of-shell # Use shell only when shell functionality is required.
  • fqcn-builtins # Use FQCN for builtin actions.
  • git-latest # Git checkouts must contain explicit version.
  • no-changed-when # Commands should not change things if nothing needs doing.
  • package-latest # Package installs should not use latest.
  • unnamed-task # All tasks should be named.
  • var-spacing # Variables should have spaces before and after: {{ var_name }}.
  • yaml # Violations reported by yamllint.

Finished with 22 failure(s), 0 warning(s) on 1 files.

yamllintで出力したエラーに対応する

yamllintで出力したエラーに対応する

roles/get_info/tasks/main.yml
4:1 warning missing document start "---" (document-start)

roles/system/tasks/main.yml
6:15 warning truthy value should be one of [false, true] (truthy)
46:14 warning truthy value should be one of [false, true] (truthy)
51:81 error line too long (97 > 80 characters) (line-length)
54:11 warning truthy value should be one of [false, true] (truthy)
79:81 error line too long (121 > 80 characters) (line-length)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.