Last active
March 1, 2024 04:49
-
-
Save na0AaooQ/09071ed37e44650820efdd07558c5dac to your computer and use it in GitHub Desktop.
Anshible を使って Amazon EC2 にyumで指定したパッケージをインストールする ref: http://qiita.com/na0AaooQ/items/4beea16dbe6a73f6f21e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: | |
- localhost | |
connection: local | |
tasks: | |
- name: update all packages | |
yum: name=* state=latest | |
become: yes | |
- name: install the latest version of gcc | |
yum: name=gcc state=latest | |
become: yes | |
- name: install the latest version of git | |
yum: name=git state=latest | |
become: yes | |
- name: install the latest version of jq | |
yum: name=jq state=latest | |
become: yes | |
- name: install the latest version of sysstat | |
yum: name=sysstat state=latest | |
become: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh ec2-user@EC2インスタンスのIPアドレス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo su - | |
# yum -y update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ sudo mkdir /etc/ansible | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ sudo vi /etc/ansible/hosts | |
[local_node] | |
127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ vi /home/ec2-user/example_playbook.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ cat /home/ec2-user/example_playbook.yml | |
--- | |
- hosts: | |
- localhost | |
connection: local | |
tasks: | |
- name: update all packages | |
yum: name=* state=latest | |
become: yes | |
- name: install the latest version of gcc | |
yum: name=gcc state=latest | |
become: yes | |
- name: install the latest version of git | |
yum: name=git state=latest | |
become: yes | |
- name: install the latest version of jq | |
yum: name=jq state=latest | |
become: yes | |
- name: install the latest version of sysstat | |
yum: name=sysstat state=latest | |
become: yes | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ ansible-playbook --syntax-check /home/ec2-user/example_playbook.yml | |
playbook: /home/ec2-user/example_playbook.yml | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ ansible-playbook --check /home/ec2-user/example_playbook.yml | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [update all packages] ***************************************************** | |
ok: [localhost] | |
TASK [install the latest version of gcc] *************************************** | |
changed: [localhost] | |
TASK [install the latest version of git] *************************************** | |
changed: [localhost] | |
TASK [install the latest version of jq] **************************************** | |
changed: [localhost] | |
TASK [install the latest version of sysstat] *********************************** | |
changed: [localhost] | |
PLAY RECAP ********************************************************************* | |
localhost : ok=6 changed=4 unreachable=0 failed=0 | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ rpm -qa | grep jq | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ rpm -qa | grep sysstat | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ rpm -qa | grep git | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ rpm -qa | grep gcc | |
libgcc48-4.8.3-9.109.amzn1.x86_64 | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ ansible-playbook /home/ec2-user/example_playbook.yml | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [update all packages] ***************************************************** | |
ok: [localhost] | |
TASK [install the latest version of gcc] *************************************** | |
changed: [localhost] | |
TASK [install the latest version of git] *************************************** | |
changed: [localhost] | |
TASK [install the latest version of jq] **************************************** | |
changed: [localhost] | |
TASK [install the latest version of sysstat] *********************************** | |
changed: [localhost] | |
PLAY RECAP ********************************************************************* | |
localhost : ok=6 changed=4 unreachable=0 failed=0 | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ ansible-playbook /home/ec2-user/example_playbook.yml | |
PLAY [localhost] *************************************************************** | |
TASK [setup] ******************************************************************* | |
ok: [localhost] | |
TASK [update all packages] ***************************************************** | |
ok: [localhost] | |
TASK [install the latest version of gcc] *************************************** | |
ok: [localhost] | |
TASK [install the latest version of git] *************************************** | |
ok: [localhost] | |
TASK [install the latest version of jq] **************************************** | |
ok: [localhost] | |
TASK [install the latest version of sysstat] *********************************** | |
ok: [localhost] | |
PLAY RECAP ********************************************************************* | |
localhost : ok=6 changed=0 unreachable=0 failed=0 | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vi /etc/sysconfig/network | |
(中略) | |
HOSTNAME=example-ansible-server | |
(中略) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ rpm -qa | grep jq | |
jq-libs-1.5-1.2.amzn1.x86_64 | |
jq-1.5-1.2.amzn1.x86_64 | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ rpm -qa | grep git | |
git-2.7.4-1.47.amzn1.x86_64 | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ rpm -qa | grep sysstat | |
sysstat-9.0.4-27.10.amzn1.x86_64 | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ rpm -qa | grep gcc | |
libgcc48-4.8.3-9.109.amzn1.x86_64 | |
gcc48-4.8.3-9.109.amzn1.x86_64 | |
gcc-4.8.3-3.20.amzn1.noarch | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ which jq | |
/usr/bin/jq | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ which git | |
/usr/bin/git | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ which sar | |
/usr/bin/sar | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ which gcc | |
/usr/bin/gcc | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ jq --version | |
jq-1.5 | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ git --version | |
git version 2.7.4 | |
[ec2-user@example-ansible-server ~]$ | |
[ec2-user@example-ansible-server ~]$ sar -v | |
Linux 4.4.19-29.55.amzn1.x86_64 (example-ansible-server) 09/25/2016 _x86_64_ (1 CPU) | |
[ec2-user@example-ansible-server ~]$ gcc --version | |
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9) | |
Copyright (C) 2013 Free Software Foundation, Inc. | |
This is free software; see the source for copying conditions. There is NO | |
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ python --version | |
Python 2.7.12 | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ uname -a | |
Linux example-ansible-server 4.4.19-29.55.amzn1.x86_64 #1 SMP Mon Aug 29 23:29:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ sudo easy_install pip | |
Searching for pip | |
Best match: pip 6.1.1 | |
Adding pip 6.1.1 to easy-install.pth file | |
Installing pip script to /usr/local/bin | |
Installing pip2.7 script to /usr/local/bin | |
Installing pip2 script to /usr/local/bin | |
Using /usr/lib/python2.7/dist-packages | |
Processing dependencies for pip | |
Finished processing dependencies for pip | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ sudo pip install ansible | |
You are using pip version 6.1.1, however version 8.1.2 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
Collecting ansible | |
Downloading ansible-2.1.1.0.tar.gz (1.9MB) | |
100% |????????????????????????????????| 1.9MB 249kB/s | |
Requirement already satisfied (use --upgrade to upgrade): paramiko in /usr/lib/python2.7/dist-packages (from ansible) | |
Requirement already satisfied (use --upgrade to upgrade): jinja2 in /usr/lib/python2.7/dist-packages (from ansible) | |
Requirement already satisfied (use --upgrade to upgrade): PyYAML in /usr/lib64/python2.7/dist-packages (from ansible) | |
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python2.7/dist-packages (from ansible) | |
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.6 in /usr/lib64/python2.7/dist-packages (from ansible) | |
Requirement already satisfied (use --upgrade to upgrade): ecdsa>=0.11 in /usr/lib/python2.7/dist-packages (from paramiko->ansible) | |
Requirement already satisfied (use --upgrade to upgrade): markupsafe in /usr/lib64/python2.7/dist-packages (from jinja2->ansible) | |
Installing collected packages: ansible | |
Running setup.py install for ansible | |
Successfully installed ansible-2.1.1.0 | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ which ansible | |
/usr/local/bin/ansible | |
[ec2-user@example-ansible-server ~]$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ec2-user@example-ansible-server ~]$ ansible --version | |
ansible 2.1.1.0 | |
config file = | |
configured module search path = Default w/o overrides | |
[ec2-user@example-ansible-server ~]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment