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
File name: hostname.yml | |
location: /u02/ansible/ansible/playbooks | |
Content of the file: | |
- hosts: all | |
- tasks: | |
- command: hostname | |
Command: | |
[ansible@calaces_dev_server2 ansible]$ ansible-playbook playbooks/hostname.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
[opc@vm04 ansible]$ ansible -m ping all | |
app02 | UNREACHABLE! => { | |
"changed": false, | |
"msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname app02: Name or service not known\r\n", | |
"unreachable": true | |
} | |
db01 | UNREACHABLE! => { | |
"changed": false, | |
"msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname db01: Name or service not known\r\n", | |
"unreachable": true |
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
[opc@vm04 ansible]$ ansible-playbook loadbalancer.yml | |
PLAY [loadbalancer] ************************************************************ | |
TASK [setup] ******************************************************************* | |
ok: [129.146.34.164] | |
TASK [install nginx] *********************************************************** | |
fatal: [129.146.34.164]: FAILED! => {"changed": false, "cmd": "apt-get update", "failed": true, "msg": "[Errno 2] No such file or directory", "rc": 2} | |
to retry, use: --limit @/home/opc/ansible/loadbalancer.retry |
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: loadbalancer | |
tasks: | |
- name: install nginx | |
apt: name=nginx state=present update_cache=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
[opc@vm04 ansible]$ ansible-playbook loadbalancer.yml | |
PLAY [loadbalancer] ************************************************************ | |
TASK [setup] ******************************************************************* | |
ok: [129.146.34.164] | |
TASK [install nginx] *********************************************************** | |
fatal: [129.146.34.164]: FAILED! => {"changed": false, "cmd": "apt-get update", "failed": true, "msg": "[Errno 2] No such file or directory", "rc": 2} | |
to retry, use: --limit @/home/opc/ansible/loadbalancer.retry |
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: loadbalancer | |
become: true | |
tasks: | |
- name: install nginx | |
apt: name=nginx state=present update_cache=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
[opc@lb01 skel]$ sudo yum repolist | |
Loaded plugins: langpacks, ulninfo | |
repo id repo name status | |
ol7_UEKR4/x86_64 Latest Unbreakable Enterprise Kernel Release 4 324 | |
ol7_addons/x86_64 Oracle Linux 7Server Add ons (x86_64) 222 | |
ol7_latest/x86_64 Oracle Linux 7Server Latest (x86_64) 18,931 | |
ol7_optional_latest/x86_64 Oracle Linux 7Server Optional Latest (x86_64) 13,141 | |
repolist: 32,618 |
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
[opc@vm04 ansible]$ ansible-playbook loadbalancer.yml | |
PLAY [loadbalancer] ************************************************************ | |
TASK [setup] ******************************************************************* | |
ok: [129.146.34.164] | |
TASK [install nginx] *********************************************************** | |
fatal: [129.146.34.164]: FAILED! => {"changed": false, "failed": true, "msg": "No package matching 'nginx' found available, installed or updated", "rc": 126, "results": ["No package matching 'nginx' found available, installed or updated"]} | |
to retry, use: --limit @/home/opc/ansible/loadbalancer.retry |
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: loadbalancer | |
become: true | |
tasks: | |
- name: install nginx | |
yum: name=nginx state=present |
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
[opc@vm04 ansible]$ ansible-playbook loadbalancer.yml | |
PLAY [loadbalancer] ************************************************************ | |
TASK [setup] ******************************************************************* | |
ok: [129.146.34.164] | |
TASK [install nginx] *********************************************************** | |
fatal: [129.146.34.164]: FAILED! => {"changed": false, "failed": true, "msg": "No package matching 'nginx' found available, installed or updated", "rc": 126, "results": ["No package matching 'nginx' found available, installed or updated"]} | |
to retry, use: --limit @/home/opc/ansible/loadbalancer.retry |
OlderNewer