Search This Blog
Saturday, 27 February 2021
Ansible playbook for apache installation using yum module
Ansible Playbook for Linux User Creation
Wednesday, 24 February 2021
Ansible playbook for apache webserver installation and configuration from source
Step 1) Copy ssh keys to remote target server.
[osboxes@master ansible-projects]$ ssh-copy-id webserverhost02
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/osboxes/.ssh/id_rsa.pub"
The authenticity of host 'webserverhost02 (192.168.1.246)' can't be established.
ECDSA key fingerprint is SHA256:QYhfRimq4gvWwsjg+kul52yjv48WfbcRHaaKgSuUQeE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
osboxes@webserverhost02's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'webserverhost02'"
and check to make sure that only the key(s) you wanted were added.
Step 2) Execute ansible ping module to check the remote server connectivity
[osboxes@master ansible-projects]$ ansible all -m ping -i webserver-inventory.txt
webserverhost02 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}
[osboxes@master ansible-projects]$ ansible-playbook install_configure_apache.yml -i webserver-inventory.txt --syntax-check
playbook: install_configure_apache.yml
Atom IDE for developing Ansible playbooks
Step 1) Download and Install Atom
https://atom.io/download/windows_x64
Step 2) Create a Project folder and Remote Sync to Linux machine where you have ansible-projects
Step 3) Enter remote machine details for connectivity
Step 5) Configurations will automatically be saved on remote machine when you save the file on local system.
Sunday, 21 February 2021
Ansible playbook for tomcat installation and configuration
Create a Linux user with expiration date
Create a user named bandaru & Set expiry date to 2021-06-30
[root@tomcathost01 ~]# useradd bandaru
[root@tomcathost01 ~]# passwd bandaru
Changing password for user bandaru.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
2) Check the expiry date for the user
[root@tomcathost01 ~]# chage -l bandaru
Last password change : Feb 21, 2021
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@tomcathost01 ~]# chage -E 2021-06-30 bandaru
[root@tomcathost01 ~]# chage -l bandaru
Last password change : Feb 21, 2021
Password expires : never
Password inactive : never
Account expires : Jun 30, 2021
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
Saturday, 20 February 2021
How to upload a file larger than 25mb into github
Step 1) Download and install git-lfs
https://github.com/git-lfs/git-lfs/releases/download/v2.13.2/git-lfs-windows-v2.13.2.exe
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/jdk (master)
$ ls -lart
total 140388
drwxr-xr-x 1 pavankumar bandaru 197121 0 Feb 20 16:08 ../
drwxr-xr-x 1 pavankumar bandaru 197121 0 Feb 20 16:09 .git/
drwxr-xr-x 1 pavankumar bandaru 197121 0 Feb 20 16:09 ./
-rw-r--r-- 1 pavankumar bandaru 197121 143722924 Feb 20 16:09 jdk-8u281-linux-x64.tar.gz
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (main)
$ git lfs install
Updated git hooks.
Git LFS initialized.
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/jdk (master)
$ git lfs track "*.gz"
Tracking "*.gz"
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (main)
$ git add .gitattributes
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (master)
pavankumar bandaru@DESKTOP-0V7CFI5 MINGW64 ~/Downloads (master)
$ git commit -m "jdk8"
[master (root-commit) fac4ee2] jdk8
2 files changed, 4 insertions(+)
create mode 100644 .gitattributes
create mode 100644 jdk-8u281-linux-x64.tar.gz
Basic Shell scripting for beginners
What is a Shell ?
shell is a command line interpreter. It is an interface between user and the kernel. It takes commands from the user and executes them.
There are different types of shells available in Linux.
Shell |
Developed By |
Path |
Default Prompt |
Bourne (sh) |
Stephen Bourne |
/bin/sh and
sbin/sh |
$ |
Korn (ksh) |
David Korn |
/bin/ksh |
$ |
Cshell (csh) |
Bill Joy |
/bin/csh |
% |
Bash (sh/bsh) |
Brain Fox |
/bin/bash |
$ |
Zsh (zsh) |
Paul Falstad |
/bin/zsh |
$ |
- Unix Defined or System Defined Variables
- User Defined Variables
HOME=/root
[root@linuxhost ~]# set | grep ^LOGNAME
LOGNAME=root
[root@linuxhost ~]# set | grep ^SHELL
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
[root@linuxhost ~]# set | grep ^MAIL
MAIL=/var/spool/mail/root
MAILCHECK=60
- Eg:- -a= ,a=,b=,c=,d=
- Eg:-a,b=10 is worng
- Eg:-name=,Name=,nAme=
- Key words are words which meaning as already been explained to the shell.
- Keywords are also called as reverse words
- The list of key words are in bourn shell: echo for if untill read else case set wait fi esas unset eval while readonly break do shift exec continue done ulimit export exit umask return frap
Ansible Certification Exam EX294
Study points for the exam
As an RHCE exam candidate, you should be able to handle all responsibilities expected of a Red Hat Certified System Administrator, including these tasks:
Be able to perform all tasks expected of a Red Hat Certified System Administrator
- Understand and use essential tools
- Operate running systems
- Configure local storage
- Create and configure file systems
- Deploy, configure, and maintain systems
- Manage users and groups
- Manage security
Understand core components of Ansible
- Inventories
- Modules
- Variables
- Facts
- Plays
- Playbooks
- Configuration files
- Use provided documentation to look up specific information about Ansible modules and commands
Install and configure an Ansible control node
- Install required packages
- Create a static host inventory file
- Create a configuration file
- Create and use static inventories to define groups of hosts
- Manage parallelism
Configure Ansible managed nodes
- Create and distribute SSH keys to managed nodes
- Configure privilege escalation on managed nodes
- Validate a working configuration using ad hoc Ansible commands
Script administration tasks
- Create simple shell scripts
- Create simple shell scripts that run ad hoc Ansible commands
Create Ansible plays and playbooks
- Know how to work with commonly used Ansible modules
- Use variables to retrieve the results of running a command
- Use conditionals to control play execution
- Configure error handling
- Create playbooks to configure systems to a specified state
Use Ansible modules for system administration tasks that work with:
- Software packages and repositories
- Services
- Firewall rules
- File systems
- Storage devices
- File content
- Archiving
- Scheduled tasks
- Security
- Users and groups
Work with roles
- Create roles
- Download roles from an Ansible Galaxy and use them
Use advanced Ansible features
- Create and use templates to create customized configuration files
- Use Ansible Vault in playbooks to protect sensitive data
Create and use templates to create customized configuration files Work with Ansible variables and facts Create and work with roles Download roles from an Ansible Galaxy and use them Manage parallelism Use Ansible Vault in playbooks to protect sensitive data Use provided documentation to look up specific information about Ansible modules and commands
As with all Red Hat performance-based exams, configurations must persist after reboot without intervention.
Ansible Roles
Roles
- tasks/main.yml - the main list of tasks that the role executes.
- handlers/main.yml - handlers, which may be used within or outside this role.
- library/my_module.py - modules, which may be used within this role (see Embedding modules and plugins in roles for more information).
- defaults/main.yml - default variables for the role (see Using Variables for more information). These variables have the lowest priority of any variables available, and can be easily overridden by any other variable, including inventory variables.
- vars/main.yml - other variables for the role (see Using Variables for more information).
- files/main.yml - files that the role deploys.
- templates/main.yml - templates that the role deploys.
- meta/main.yml - metadata for the role, including role dependencies.
Storing and finding roles
- at the play level with the roles option: This is the classic way of using roles in a play.
- at the tasks level with include_role: You can reuse roles dynamically anywhere in the tasks section of a play using include_role.
- at the tasks level with import_role: You can reuse roles statically anywhere in the tasks section of a play using import_role.
- If roles/x/tasks/main.yml exists, Ansible adds the tasks in that file to the play.
- If roles/x/handlers/main.yml exists, Ansible adds the handlers in that file to the play.
- If roles/x/vars/main.yml exists, Ansible adds the variables in that file to the play.
- If roles/x/defaults/main.yml exists, Ansible adds the variables in that file to the play.
- If roles/x/meta/main.yml exists, Ansible adds any role dependencies in that file to the list of roles.
- Any copy, script, template or include tasks (in the role) can reference files in roles/x/{files,templates,tasks}/ (dir depends on task) without having to path them relatively or absolutely.
- Any pre_tasks defined in the play.
- Any handlers triggered by pre_tasks.
- Each role listed in roles:, in the order listed. Any role dependencies defined in the role’s meta/main.yml run first, subject to tag filtering and conditionals.
- Any tasks defined in the play.
- Any handlers triggered by the roles or tasks.
- Any post_tasks defined in the play.
- Any handlers triggered by post_tasks.