-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab4.sh
More file actions
65 lines (41 loc) · 1.45 KB
/
Lab4.sh
File metadata and controls
65 lines (41 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
chmod 400 KEYNAME.pem
ssh ubuntu@ec2-54-173-37-229.compute-1.amazonaws.com -i lab4.pem
sudo apt update
sudo apt install ansible
ansible --version
# Copy the ssh private key from the sandbox to the newly created VM and save it at /home/ubuntu/lab_user.pem
# ON YOUR MACBOOK TERMINAL
scp -i ~/Downloads/lab4.pem ~/Downloads/lab4.pem ubuntu@54.173.37.229:/home/ubuntu/lab_user.pem
# UBUNTU TERMINAL AGAIN
chmod 600 /home/ubuntu/ansible-key.pem
ansible all --inventory "localhost," --module-name debug --args "msg='Hello'"
aws_hosts1 file added and later edited by using:
> aws_hosts1
nano aws_hosts1
control + X
Y
enter
# To display the content of the file aws_hosts1
echo "$(<aws_hosts1 )"
[aws]
ec2-54-173-37-229.compute-1.amazonaws.com
ec2-3-92-27-206.compute-1.amazonaws.com
[aws:vars]
ansible_ssh_user=ubuntu
ansible_ssh_private_key_file=/home/ubuntu/lab_user.pem
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
# Adding playbook_example.yml again through > and nano
# Executing a notebook
# Docker Swarm
ansible_cluster_hosts:
[master]
ec2-54-152-246-215.compute-1.amazonaws.com
[worker]
ec2-18-212-232-201.compute-1.amazonaws.com
[cluster:children]
master
worker
[cluster:vars]
ansible_ssh_user=ubuntu
ansible_ssh_private_key_file=/home/ubuntu/lab_user.pem
ansible_ssh_common_args='-o StrictHostKeyChecking=no'