Posts

Showing posts from July, 2020

Digital Marketing

Ansible Dry Run

When ansible-playbook is executed with --check it will not make any changes on remote systems.  Example: ansible --connection=local   -m ping localhost --check localhost | SUCCESS => {     "changed": false,     "ping": "pong" } Sometimes you may want to modify the check mode behavior of individual tasks. This is done via the  check_mode  option, which can be added to tasks. There are two options: Force a task to  run in check mode , even when the playbook is called  without   --check . This is called  check_mode:   yes . Force a task to  run in normal mode  and make changes to the system, even when the playbook is called  with   --check . This is called  check_mode:   no .

Ansible Ad-hoc command for localhost example

# ansible --connection=local   -m ping localhost localhost | SUCCESS => {     "changed": false,     "ping": "pong" ansible --connection=local   -m command -a "uname -r" localhost localhost | CHANGED | rc=0 >> 4.14.181-142.260.amzn2.x86_64

Install python-virtualenv

Python virtual environment of venv module provides developers the capability of creating a quite lightweight virtual environment with its standalone directory.  # dnf -y install python-virtualenv

Install Ansible on Docker Fedora

# dnf -y install ansible # ansible --version ansible 2.9.10

Delete a Git branch

$ git push -d <remote_name> <branch_name> $ git branch -d <branch_name> Normally the remote name is origin. In most case you'll have to use the command like: $ git push -d origin <branch_name> To delete Local Branch To delete the local branch use one of the following: $ git branch -d branch_name $ git branch -D branch_name The -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch.  By contrast -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status." If other machines have the branch, you can run git branch -a to verify. To get rid of the branch on other machines run git fetch --all --prune

Setup Git merge for automatic resolving

git rerere Recorded Reused Resolution Enabling rerere git config --global rerere.autoupdate true

Fixed: windows 10 no sound without headphones

Please go to control panel -> hardware and sound -> sound In the playback tab ,  Please enable and set your laptop speakers as the default device If you cannot set  speakers as the default device, do the following: go to start search and type cmd search will return cmd.exe right click on this and select 'run as administrator' at the prompt type:- net localgroup Administrators /add networkservice, press enter then type: net localgroup Administrators /add localservice, press enter then type: exit, press enter   restart your computer

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible.

Ansible Vault is an excellent tool for encrypting sensitive data

There are sensitive data that a playbook needs to operate on, be that for playbook data in the form of variables or storing server credentials themselves, such as an SSH private key.

AWX can help with the security of Ansible automation

Install Jinja 2

pip install jinja2 easy_install jinja2

A list in YAML lists all of its items at the same indentation level, with each line starting with -.

YAML is easier for humans to read and write than other common data formats, such as XML or JSON.

Jinja is a web template engine for the Python programming language.

Jinja was created by Armin Ronacher and is licensed under a BSD License. Jinja is similar to the Django template engine but provides Python-like expressions while ensuring that the templates are evaluated in a sandbox. It is a text-based template language and thus can be used to generate any markup as well as source code.

Ansible Roles

Ansible  Roles are by default run from a subdirectory called roles/, in the same directory as your playbook.  Ansible will also search for roles in /etc/ansible/roles and the paths specified by the roles_path parameter in the Ansible configuration file ( such as /etc/ansible/ansible.cfg)

ssh-agent: set up SSH agent to avoid retyping passwords

To set up SSH agent to avoid retyping passwords, you can do: $ ssh-agent bash $ ssh-add ~/.ssh/id_rsa

Silently creates a 2048-bit RSA key in the file at ~/.ssh/id_rsa, with no passphrase

$ ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ''

Gmail Confidential Mode

In the Gmail app on iOS or Android: after composing your email, tap the three-dots button. ... Tap Confidential Mode. Tap Expires in 1 week. Set an expiration time, and tap Done. Tap Standard. Select between SMS passcode delivery or Standard Confidential mode, and tap Done. Tap the Check mark. Tap Send.

Linux History Command

To run the last command you used enter: !! You can also run a command that was much earlier in the history list. To do so, enter the following, where n is the line you wish to run: ![n] To run the last command that used a specific string, enter: ![string]

Install Ansible on 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 Verify: $ ansible --version

Use Ansible setup module to gather facts

Display gathered facts Display gathered facts about your inventory hosts using the following command: $ ansible all -i hosts -m setup | less Display all facts about all the hosts in your inventory $ ansible all -m setup 

How to start ssh-agent and add your private key to it.

$ ssh-agent bash  $ ssh-add ~/.ssh/id_rsa

Ansible supports password authentication through the use of the --ask-pass switch.

Oracle/RHEL (Red Hat)/CentOS Linux install Python

Type the following yum command: $ sudo dnf install python38

Check SSL / TLS version support by nmap

$ nmap --script ssl-enum-ciphers -p 443 www.goyun.info Starting Nmap 6.40 ( http://nmap.org ) at 2020-07-21 13:52 EDT Nmap scan report for www.goyun.info (172.217.13.115) Host is up (0.0011s latency). rDNS record for 172.217.13.115: yul02s04-in-f19.1e100.net PORT    STATE SERVICE 443/tcp open  https | ssl-enum-ciphers: |_  TLSv1.0: No supported ciphers found Nmap done: 1 IP address (1 host up) scanned in 0.32 seconds

The ‘git fsck’ command is useful for performing an integrity evaluation of the Git file system and the identification of corrupted objects.

$ git fsck Checking object directories: 100% (256/256), done. Checking objects: 100% (10060/10060), done.

The ‘git gc’ command is a garbage collector command.

The ‘git gc’ command helps in collection of garbage from a repository and ensuring optimization of the repository. Users should also ensure that the command is run periodically. The example of using the command is as follows, $ git gc Enumerating objects: 10060, done. Counting objects: 100% (10060/10060), done. Delta compression using up to 8 threads Compressing objects: 100% (1623/1623), done. Writing objects: 100% (10060/10060), done. Total 10060 (delta 4510), reused 9960 (delta 4483)

Most popular DevOps tools

Git – It’s a well-known DevOps tool used for distributed source code management. Jenkins – This tool is a continuous integration tool that provides running tests on a non-developer machine when new code pushed into the source repository. Docker – Docker is a tool used at the time of its continuous deployment stage of DevOps to achieve containerization of OS and its dependencies.

Rename a Docker Container

$ sudo docker rename goyun goyun_info

Selenium is a DevOps tool that is built specifically to aid developers in creating automated regression tests to assure that their program is working as intended.

Docker provides developers to easily create, package, and deploy their code through containers which are packaged with the required dependencies.

Kubernetes is a container management DevOps tool that is ideal for applications that come packaged with an overwhelming amount of containers.

Ansible is a software automation tool.

Ansible is also a great IT Configuration management tool.

Ansible makes the configuration and automation management a lot easier than before.

Most of the developers are now trying to automate the development process and production environment.  When it comes to software development, automation plays a significant role. 

Linux list all users account using the /etc/passwd file

Type any one of the following command: $ cat /etc/passwd

Get the Service Tag via DELL iDRAC SSH

Type the following command lines to show the service tag: cd hdwr2 cd chassis1 show The “Serial Number” field is the Service Tag.

Get DELL Service Tag on remote Linux system

dmidecode -s system-serial-number

Testing Connectivity to Ansible Nodes

To test that Ansible is able to connect and run commands and playbooks on your nodes, you can use the following command: ansible all -m ping The ping module will test if you have valid credentials for connecting to the nodes defined in your inventory file, in addition to testing if Ansible is able to run Python scripts on the remote server. A pong reply back means Ansible is ready to run commands and playbooks on that node.

Ansible Check Mode (“Dry Run”)

ansible-playbook goyun.info.yml --check

System vs Regular Users

Linux users can be "system" users or "normal" users.  Regular users typically have UID's at 1000 or higher and are allowed to log into the server. System users often have a user id (UID) below 1000 and cannot be used to login. They are usually used to run programs. For example, users www-data or apache are often used to run web servers. See the file /etc/login.defs to find variables like UID_MIN and UID_MAX set for system vs regular users: # # Min/max values for automatic uid selection in useradd # UID_MIN 1000 UID_MAX 60000 # System accounts SYS_UID_MIN 201 SYS_UID_MAX 999 # # Min/max values for automatic gid selection in groupadd # GID_MIN 1000 GID_MAX 60000 # System accounts SYS_GID_MIN 201 SYS_GID_MAX 999

List All Linux Groups

less /etc/group

Regenerating Linux Hashed Password in Python

You can use python crypt implementation to regenerate Linux password >>> import crypt >>> password="goyun.info" >>> hashing_scheme_with_salt="$6$goyuninfo$" >>> crypt.crypt(password, hashing_scheme_with_salt) '$6$goyuninfo$yLqTuT5hzDWwBOF1ryt82mnbhrTTeMSr25i/6zUDZJIV7o9bMONICzK1/GGtK8RW4QXHF89ZgxjhiDMKZ.fso0' Stored password hash is generated using crypt3.

Ubuntu Password File Location and Content

Ubuntu stores password content in file /etc/shadow. Along with hashed password this file also stores content like username, password change date, expiry date etc. in colon (:) separated format.  Only root user can write inside this file.

Linux passwords are hashed not encrypted

In Linux Passwords are not stored by encrypting with some secret key rather hash of the password is stored.  There is no worry about key getting compromised or the file which actually stores password (Hashed Password) getting stolen. To make storage more secure password are hashed with salt . Salt is just random string which is generated when you create password. This helps prevent rainbow table attacks.

What does 'grep -v' do

-v means "invert the match" in grep, in other words, return all non matching lines.

Check Ansible Version

$ ansible --version ansible 2.9.10   config file = /etc/ansible/ansible.cfg   configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']   ansible python module location = /usr/lib/python2.7/site-packages/ansible   executable location = /usr/bin/ansible   python version = 2.7.18 (default, May 27 2020, 12:45:48) [GCC 7.3.1 20180712 (Red Hat 7.3.1-6)]

Linux is popular among large organisations as well as among regular computer users.

 Linux is used for server environments because of the reliability and stability.

Sample NFS fstab entry

192.168.0.20:/var/www/html/ /var/www/html/   nfs     defaults,nofail        0 0

xargs and kill example

sudo ps -ef | grep java | grep email | awk '{print $2}' | xargs sudo kill -9

Ansible configuration file

Changes can be made and used in a configuration file which will be searched for in the following order: ANSIBLE_CONFIG (environment variable if set) ansible.cfg (in the current directory) ~/.ansible.cfg (in the home directory) /etc/ansible/ansible.cfg Ansible will process the above list and use the first file found, all others are ignored.

Ansible ships with a number of handy plugins

Plugins are pieces of code that augment Ansible’s core functionality. Ansible uses a plugin architecture to enable a rich, flexible and expandable feature set.

Ansible Hosts File Comments

If you want to put a comment next to any item in your Ansible Hosts file just start a new line with a #

Ansible includes a shell module that can be used to execute commands on remote machines.

When a subclass inherits from a superclass, it also inherits its methods; however, it can also override the superclass methods

When overriding a method, you should precede it with the @Override annotation. The parameter(s) and return type of an overridden method must be exactly the same as those of the method inherited from the supertype.

HashSet in Java

HashSet internally uses a HashMap to store its elements. HashSet is not thread-safe. HashSet allows null value.

Disable Ansible Host key checking

Editing /etc/ansible/ansible.cfg or ~/.ansible.cfg: [defaults] host_key_checking = False

Checking host keys guards against server spoofing and man-in-the-middle attacks

Undo changes in vim / Vi

Press the Esc key to go back to the normal mode ESC Type u to undo the last change. To undo the two last changes, you would type 2u. Press Ctrl-r to redo changes which were undone. In other words, undo the undos. Typically, known as redo.

Ansible will stop all further execution and require you to fix the problem before running the playbook again.

How to find Linkedin company page id

From the company page, check Notifications  tab, the link of Notifications contains company page id in the URL. If you cannot find Notifications tab, then you can view page source, and search for "companyid".

How to change Google cloud SQL timezone

Change MySQL Flag  default_time_zone to the value you want. For example, to change to Eastern Standard time: change default_time_zone to -05:00

How to change Google cloud SQL timezone

Change MySQL Flag  default_time_zone to the value you want. For example, to change to Eastern Standard time: change default_time_zone to -05:00

Showing Git Remotes

To see which remote servers you have configured, you can run the git remote command. You can also specify -v, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote: $ git remote -v

Watch out for LEFT JOIN with additional conditions in SQL

SELECT  * FROM    a LEFT JOIN b ON      b.a_id = a.id WHERE   b.column = 'sth' Return the same result as (but less efficient) SELECT  * FROM    a INNER JOIN b ON      b.a_id = a.id WHERE   b.column = 'sth' Put additional conditions on left table on left join will actually filter out those rows where b.column is null. Because   NULL in SQL  doesn't equal to anything. So the only exception to put extra condition on left table of left join is to check b.column is null or not. If you actually want to return those  b.column = 'sth' and at the same time with all records of table a, then the condition should be moved into ON clause: SELECT  * FROM    a LEFT JOIN         b ON      b.a_id = a.id AND b.column = 'sth'

Exposing RDP/SSH ports over the Internet isn't desired and is seen as a significant threat surface.

This is often due to protocol vulnerabilities. To contain this threat surface, you can deploy bastion hosts (also known as jump-servers) at the public side of your perimeter network. Bastion host servers are designed and configured to withstand attacks. Bastion servers also provide RDP and SSH connectivity to the workloads sitting behind the bastion, as well as further inside the network.

Email spamming related to IP address

Waterfalling – is when multiple Email Sending providers ( ESP ) are being used to send email. In this case, each ESP is using it’s own block of IP addresses. Spammers use one ESP to clean their lists, also called scrubbing, and another to send the actual marketing email. This technique is used by spammers and gray mailers. Snowshoe Spamming – is a spamming technique where a wide range of IP addresses are used to spread out the spam send rate and or load. Using a wide range of IP addresses makes it difficult for ISP’s to successfully identify the spam resulting in some of the spam to slip through. IP hopping – is simply using one set of IP addresses today, and next week you use new ones. ISP’s might throw you into the category of Snowshoeing or Waterfalling. If for some reason you have to change your IP’s, make sure they get warmed up properly, by relaying only a few mails per day through them. It takes a very long time to build a proper reputation for IP’s. The complete IP check for se...

Watch out for LEFT JOIN with additional conditions in SQL

SELECT  * FROM    a LEFT JOIN b ON      b.a_id = a.id WHERE   b.column = 'sth' Return the same result as (but less efficient) SELECT  * FROM    a INNER JOIN b ON      b.a_id = a.id WHERE   b.column = 'sth' Put additional conditions on left table on left join will actually filter out those rows where b.column is null. Because   NULL in SQL  doesn't equal to anything. So the only exception to put extra condition on left table of left join is to check b.column is null or not. If you actually want to return those  b.column = 'sth' and at the same time with all records of table a, then the condition should be moved into ON clause: SELECT  * FROM    a LEFT JOIN         b ON      b.a_id = a.id AND b.column = 'sth'

The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS

If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started. * [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) * [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html) * [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html) * [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)

MySQL Sandbox with the Sakila sample database

You can go to https://www.katacoda.com/mysql-db-sandbox/scenarios/mysql-sandbox to access the MySQL Sandbox, which has the Sakila sample database loaded in a MySQL instance. You’ll have to set up a (free) Katacoda account. Then, click the Start Scenario button. See also: https://dev.mysql.com/doc/index-other.html

How to delete many rows from a large table in MySQL

If you want to delete many rows from a large table, you may exceed the lock table size for an InnoDB table. To avoid this problem, or simply to minimize the time that the table remains locked, the following strategy (which does not use DELETE at all) might be helpful: Select the rows not to be deleted into an empty table that has the same structure as the original table: create table t_copy like t; insert into t_copy SELECT * FROM t WHERE ... ; See also: How to Copy Table in MySQL Use RENAME TABLE to atomically move the original table out of the way and rename the copy to the original name: RENAME TABLE t TO t_old, t_copy TO t; Drop the original table: DROP TABLE t_old; Note that Foreign keys that point to the renamed table are not automatically updated. In such cases, you must drop and re-create the foreign keys in order for them to function properly. If you need a smaller table for development, to keep the foreign keys: create table contacts_new like contacts; insert into c...

How to delete many rows from a large table in MySQL

If you want to delete many rows from a large table, you may exceed the lock table size for an InnoDB table. To avoid this problem, or simply to minimize the time that the table remains locked, the following strategy (which does not use DELETE at all) might be helpful: Select the rows not to be deleted into an empty table that has the same structure as the original table: create table t_copy like t; insert into t_copy SELECT * FROM t WHERE ... ; See also: How to Copy Table in MySQL Use RENAME TABLE to atomically move the original table out of the way and rename the copy to the original name: RENAME TABLE t TO t_old, t_copy TO t; Drop the original table: DROP TABLE t_old; Note that Foreign keys that point to the renamed table are not automatically updated. In such cases, you must drop and re-create the foreign keys in order for them to function properly. If you need a smaller table for development, to keep the foreign keys: create table contacts_new like contacts; insert into c...

Java Http Client

Although the java.net package provides basic functionality for accessing resources via HTTP, it doesn't provide the full flexibility or functionality needed by many applications. HttpClient seeks to fill this void by providing an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. Designed for extension while providing robust support for the base HTTP protocol, HttpClient may be of interest to anyone building HTTP-aware client applications such as web browsers, web service clients, or systems that leverage or extend the HTTP protocol for distributed communication. (Apache Commons HttpClient is an old project which  is now deprecated  that produced HttpClient 3.1. The project was subsumed by the larger Apache HttpComponents project, which produced HttpClient 4.x.) Restful implementation Jersey provides  ApacheHttpClient Class which is a Client that utilizes the Apache HTTP client to send and...

One-time job on Linux

at utility is very simple to use, and you can fire off a one-time job without a lot of fuss. Run at time < script.sh and at will run the script and then exit. For example: at 8am -f script.sh Will run the script at 8 a.m. -- if it's past 8 a.m., then it will run the job tomorrow. And that's it; the job will run once. If you want to see what's scheduled, just use the atq command to see what you will be running.  Note that the -f option specifies a file for the command input, whereas you can also just provide the commands via standard input (such as using the < script.sh method).

How to add user to a Group in Linux

Add user to a Group usermod - modify user account A user does not belong to a specific group could cause application problem. To check a user's existing group: $ id user_name To add an existing user to a group: # usermod -aG group-name user-name For example, to add user ec2-user to docker group: $ sudo usermod -aG docker ec2-user You need to logout and login to see the effect. Be careful not to use # usermod -g group-name user-name It will change the user's primary group, instead of just adding to the group.

HTML Element Reference

HTML5 - Tags Reference Tag Description <!--...--> Specifies a comment <!DOCTYPE> Specifies the document type <a> Specifies an anchor <abbr> Specifies an abbreviation <acronym> Deprecated: Specifies an acronym <address> Specifies an address element <applet> Deprecated:  Specifies an applet <area> Specifies an area inside an image map <article> New Tag:  Specifies an independent piece of content of a document, such as a blog entry or newspaper article <aside> New Tag: Specifies a piece of content that is only slightly related to the rest of the page. <audio> New Tag: Specifies an audio file. <base> Specifies a base URL for all the links in a page <basefont> Deprecated:  Specifies a base font <bdo> Specifies the direction of text display <bgsound> Specifies the background music <blink> Specifies a text which blinks <blockquote> Specifies a long quotation <body> Specifi...