Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lerndevops/labs
Browse files Browse the repository at this point in the history
  • Loading branch information
lerndevopss committed Jul 3, 2021
2 parents b88ab8a + a84b84a commit 3c6c4b3
Show file tree
Hide file tree
Showing 282 changed files with 43,112 additions and 43,036 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
54 changes: 27 additions & 27 deletions ansible/Tower
100644 → 100755
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
92 changes: 46 additions & 46 deletions ansible/ad-hoc/readme.md
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 modified ansible/ansible-commands.txt
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions ansible/dockerrole.yml
100644 → 100755
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
22 changes: 11 additions & 11 deletions ansible/install/InsallAnsible.txt
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
52 changes: 26 additions & 26 deletions ansible/install/TowerSetup
100644 → 100755
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

62 changes: 31 additions & 31 deletions ansible/install/ssh-keys-setup.md
100644 → 100755
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)
```


22 changes: 11 additions & 11 deletions ansible/playbooks/06copy.yml
100644 → 100755
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
...
30 changes: 15 additions & 15 deletions ansible/playbooks/07loops1.yml
100644 → 100755
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
...
Loading

0 comments on commit 3c6c4b3

Please sign in to comment.