forked from lerndevops/labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/lerndevops/labs
- Loading branch information
Showing
282 changed files
with
43,112 additions
and
43,036 deletions.
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
1 git clone http://github.com/lerndevops/labs | ||
2 cd labs/ansible/install/ | ||
3 ./installAnsible.sh | ||
5 apt-get install software-properties-common | ||
6 add-apt-repository ppa:deadsnakes/ppa | ||
7 apt-get update | ||
8 apt-get install python3.6 | ||
9 apt-get remove python2.7 | ||
10 cd .. | ||
11 cd docker/ | ||
12 ./install/installDocker.sh | ||
13 cd | ||
14 git clone https://github.com/ansible/awx | ||
15 cd awx/installer/ | ||
16 ls | ||
17 ansible --version | ||
18 cd | ||
19 cd labs/ansible/install/ | ||
20 ./installAnsible.sh | ||
21 cd | ||
22 cd awx/ | ||
23 cd installer/ | ||
32 apt install python3-docker | ||
38 apt-get install python3-pip | ||
39 pip3 install docker-compose | ||
40 ansible-playbook -i inventory install.yml | ||
docker ps | ||
1 git clone http://github.com/lerndevops/labs | ||
2 cd labs/ansible/install/ | ||
3 ./installAnsible.sh | ||
5 apt-get install software-properties-common | ||
6 add-apt-repository ppa:deadsnakes/ppa | ||
7 apt-get update | ||
8 apt-get install python3.6 | ||
9 apt-get remove python2.7 | ||
10 cd .. | ||
11 cd docker/ | ||
12 ./install/installDocker.sh | ||
13 cd | ||
14 git clone https://github.com/ansible/awx | ||
15 cd awx/installer/ | ||
16 ls | ||
17 ansible --version | ||
18 cd | ||
19 cd labs/ansible/install/ | ||
20 ./installAnsible.sh | ||
21 cd | ||
22 cd awx/ | ||
23 cd installer/ | ||
32 apt install python3-docker | ||
38 apt-get install python3-pip | ||
39 pip3 install docker-compose | ||
40 ansible-playbook -i inventory install.yml | ||
docker ps |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
`Ad-Hoc commands are one-liner ansible commands that performs one task on the target host.` | ||
`It allows you to execute simpleone-line task against one or group of hosts defined on the inventory file configuration.` | ||
|
||
## Ansible Ad-Hoc Commands to use when SSH Keys configured with target hosts | ||
|
||
``` | ||
how to run ansible ad-hoc commands ( default inventory ) | ||
ansible all -m setup | ||
ansible qa -m ping | ||
ansible dev -m shell -a "free -m" | ||
ansible iat -m copy -a "src=/tmp/naresh.txt dest=/tmp" | ||
ansible prod -m file -a "path=/tmp/helousername.txt state=touch" | ||
how to run ansible ad-hoc with custom inventory | ||
ansible all -i /path/to/inventory ping | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" | ||
how to run ansible ad-hoc with super user (root) | ||
ansible all -i /path/to/inventory -b ping | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" -b | ||
``` | ||
|
||
## Ansible Ad-Hoc Commands to use when No SSH Keys configured with target hosts | ||
|
||
``` | ||
how to run ansible ad-hoc commands ( default inventory ) with uid/pwd | ||
ansible all -m setup -u username -k | ||
ansible qa -m ping -u username -k | ||
ansible dev -m shell -a "free -m" -u username -k | ||
ansible iat -m copy -a "src=/tmp/naresh.txt dest=/tmp" -u username -k | ||
ansible prod -m file -a "path=/tmp/helousername.txt state=touch" -u username -k | ||
how to run ansible ad-hoc with custom inventory & uid/pwd | ||
ansible all -i /path/to/inventory -u username -k | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" -u username -k | ||
how to run ansible ad-hoc with super user (root) with uid/pwd | ||
ansible all -i /path/to/inventory -b -u username -k -K | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" -b -u username -k -K | ||
``` | ||
`Ad-Hoc commands are one-liner ansible commands that performs one task on the target host.` | ||
`It allows you to execute simpleone-line task against one or group of hosts defined on the inventory file configuration.` | ||
|
||
## Ansible Ad-Hoc Commands to use when SSH Keys configured with target hosts | ||
|
||
``` | ||
how to run ansible ad-hoc commands ( default inventory ) | ||
ansible all -m setup | ||
ansible qa -m ping | ||
ansible dev -m shell -a "free -m" | ||
ansible iat -m copy -a "src=/tmp/naresh.txt dest=/tmp" | ||
ansible prod -m file -a "path=/tmp/helousername.txt state=touch" | ||
how to run ansible ad-hoc with custom inventory | ||
ansible all -i /path/to/inventory ping | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" | ||
how to run ansible ad-hoc with super user (root) | ||
ansible all -i /path/to/inventory -b ping | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" -b | ||
``` | ||
|
||
## Ansible Ad-Hoc Commands to use when No SSH Keys configured with target hosts | ||
|
||
``` | ||
how to run ansible ad-hoc commands ( default inventory ) with uid/pwd | ||
ansible all -m setup -u username -k | ||
ansible qa -m ping -u username -k | ||
ansible dev -m shell -a "free -m" -u username -k | ||
ansible iat -m copy -a "src=/tmp/naresh.txt dest=/tmp" -u username -k | ||
ansible prod -m file -a "path=/tmp/helousername.txt state=touch" -u username -k | ||
how to run ansible ad-hoc with custom inventory & uid/pwd | ||
ansible all -i /path/to/inventory -u username -k | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" -u username -k | ||
how to run ansible ad-hoc with super user (root) with uid/pwd | ||
ansible all -i /path/to/inventory -b -u username -k -K | ||
ansible dev -i /path/to/inventory -m copy -a "src=/tmp/new.txt dest=/tmp" -b -u username -k -K | ||
``` |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- docker | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- docker |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
Installation Steps for Ubuntu | ||
==================================================================== | ||
sudo apt-get update | ||
sudo apt-get install software-properties-common | ||
sudo apt-add-repository --yes --update ppa:ansible/ansible | ||
sudo apt-get install ansible | ||
Installation Steps for centos | ||
===================================================================== | ||
Installation Steps for Ubuntu | ||
==================================================================== | ||
sudo apt-get update | ||
sudo apt-get install software-properties-common | ||
sudo apt-add-repository --yes --update ppa:ansible/ansible | ||
sudo apt-get install ansible | ||
|
||
|
||
Installation Steps for centos | ||
===================================================================== | ||
|
||
devops/devops |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
1 git clone https://github.com/ansible/awx | ||
2 git clone https://github.com/lerndevops/labs | ||
3 cd labs/ | ||
4 cd ansible/ | ||
5 ./installAnsible.sh | ||
6 apt-get update | ||
9 apt install python3-pip | ||
10 apt-get update | ||
11 sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | ||
12 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
13 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) \ | ||
stable" | ||
14 sudo apt-get update | ||
15 apt-get install docker-ce docker-ce-cli containerd.io | ||
16 docker -v | ||
18 apt install python-pip | ||
19 pip install docker-compose | ||
22 cd ../.. | ||
23 cd awx/ | ||
24 ls | ||
25 cd installer/ | ||
26 ls | ||
28 ansible-playbook -i inventory install.yml | ||
29 docker ps | ||
1 git clone https://github.com/ansible/awx | ||
2 git clone https://github.com/lerndevops/labs | ||
3 cd labs/ | ||
4 cd ansible/ | ||
5 ./installAnsible.sh | ||
6 apt-get update | ||
9 apt install python3-pip | ||
10 apt-get update | ||
11 sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | ||
12 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
13 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) \ | ||
stable" | ||
14 sudo apt-get update | ||
15 apt-get install docker-ce docker-ce-cli containerd.io | ||
16 docker -v | ||
18 apt install python-pip | ||
19 pip install docker-compose | ||
22 cd ../.. | ||
23 cd awx/ | ||
24 ls | ||
25 cd installer/ | ||
26 ls | ||
28 ansible-playbook -i inventory install.yml | ||
29 docker ps | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
### create a user on all machines ( controller & all targets ) | ||
|
||
useradd naresh -m -d /home/naresh -s /bin/bash | ||
|
||
### add user to sudoers for root previliges on all machines ( all targets ) | ||
|
||
echo -e 'naresh ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/naresh | ||
|
||
### genereate ssh keys for above user on contrller machine | ||
|
||
``` | ||
1) switch to user ( su - naresh ) | ||
2) run "ssh-keygen" command as user ( this will genereate ssh keys for the user ) | ||
``` | ||
``` | ||
on ansible controller machine | ||
cd /home/naresh/.ssh | ||
cat id_rsa.pub (copy the content) | ||
``` | ||
### copy user ssh keys from ansible contrller to all target hosts | ||
|
||
``` | ||
1) on all target machines | ||
swith to the user ( su - naresh ) | ||
mkdir -p /home/naresh/.ssh | ||
touch /home/naresh/.ssh/authorized_keys | ||
chmod -R 700 /home/naresh/.ssh | ||
vi /home/naresh/.ssh/authorized_keys (enter the copied contet of id_rsa.pub from controller & save the file) | ||
``` | ||
|
||
|
||
### create a user on all machines ( controller & all targets ) | ||
|
||
useradd naresh -m -d /home/naresh -s /bin/bash | ||
|
||
### add user to sudoers for root previliges on all machines ( all targets ) | ||
|
||
echo -e 'naresh ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/naresh | ||
|
||
### genereate ssh keys for above user on contrller machine | ||
|
||
``` | ||
1) switch to user ( su - naresh ) | ||
2) run "ssh-keygen" command as user ( this will genereate ssh keys for the user ) | ||
``` | ||
``` | ||
on ansible controller machine | ||
cd /home/naresh/.ssh | ||
cat id_rsa.pub (copy the content) | ||
``` | ||
### copy user ssh keys from ansible contrller to all target hosts | ||
|
||
``` | ||
1) on all target machines | ||
swith to the user ( su - naresh ) | ||
mkdir -p /home/naresh/.ssh | ||
touch /home/naresh/.ssh/authorized_keys | ||
chmod -R 700 /home/naresh/.ssh | ||
vi /home/naresh/.ssh/authorized_keys (enter the copied contet of id_rsa.pub from controller & save the file) | ||
``` | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
--- | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: Copy ansible inventory file to all hostmachines | ||
copy: src=/etc/ansible/ansible.cfg | ||
dest=/tmp/ | ||
owner=root | ||
group=root | ||
mode=0666 | ||
... | ||
--- | ||
- hosts: all | ||
become: true | ||
tasks: | ||
- name: Copy ansible inventory file to all hostmachines | ||
copy: src=/etc/ansible/ansible.cfg | ||
dest=/tmp/ | ||
owner=root | ||
group=root | ||
mode=0666 | ||
... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#This playbbok will install HTTP server,wget and vim package using loops. | ||
|
||
--- | ||
- hosts: localhost | ||
become: true | ||
tasks: | ||
- name: Install list of packages | ||
yum: name='{{item}}' state=present | ||
with_items: | ||
- httpd | ||
- wget | ||
- vim | ||
- zip | ||
- unzip | ||
... | ||
#This playbbok will install HTTP server,wget and vim package using loops. | ||
|
||
--- | ||
- hosts: localhost | ||
become: true | ||
tasks: | ||
- name: Install list of packages | ||
yum: name='{{item}}' state=present | ||
with_items: | ||
- httpd | ||
- wget | ||
- vim | ||
- zip | ||
- unzip | ||
... |
Oops, something went wrong.