Posts

Showing posts from September, 2021

Useful Ansible commands

Help: [#> ansible --help] Version: [#> ansible --version] #> ansible --version ansible 2.0.0.2 config file = /etc/ansible/ansble.cfg configured module search path = Default w/o overrides Check: [#> ansible foo.yml --check] Inventory: [#> ansible -i 192.x.x.x, x.x.x.x] ListHosts: [#> ansible -list-hosts] OneLine: [#> ansible –-one-line] SyntaxCheck: [#> ansible –-syntax-check] TimeOut: [#> ansible –timeout=X] Verbose: [#> ansible –verbose] Example: Run an ad hoc command against an Ansible inventory group and limit the execution of a playbook to a max of 5 simultaneous servers: $ ansible europe -a "whoami" -f 5 Example: Execute a playbook against the Europe group as a privileged account (different from the SSH account $ ansible europe -a "/usr/bin/foo" -u username --become [ --ask-become-pass ] Example: Transfer a local (on the ansible control server) file to a set of remote hosts simultaneously $ ansible europe -m copy -a "src=/op...

How to install Ansible

https://www.snel.com/support/how-to-install-ansible-on-centos-7/ Install Ansible on Ubuntu $ sudo apt-get install software-properties-common $ sudo apt-add-repository ppa:ansible/ansible $ sudo apt-get update $ sudo apt-get install ansible Install Ansible on Centos # NOTE: Before installing Ansible you may need to install the epel-release repo # for RHEL or # Scientific Linux. Additional details on how to install EPEL can be found at # http://fedoraproject.org/wiki/EPEL $ sudo yum install ansible For Gentoo Linux users, installing Ansible can be accomplished fairly easily. The following command-line syntax can be leveraged to accomplish the installation: # The first command is optional, you may need to unmask the Ansible package prior to running emerge: $ echo 'app-admin/ansible' >> /etc/portage/package.accept_keywords $ emerge -av app-admin/ansible PKG for FreeBSD FreeBSD-specific users can use  pkg install  to install the Ansible control server solution and get Ansible...

Upload file to S3

 gradle implementation 'com.amazonaws:aws-java-sdk:1.11.163' import java.io.File ; import org.springframework.beans.factory.annotation. Value ; import org.springframework.context.annotation. Bean ; import org.springframework.context.annotation. Configuration ; import com.amazonaws.ClientConfiguration ; import com.amazonaws.Protocol ; import com.amazonaws.auth.AWSCredentials ; import com.amazonaws.auth.AWSStaticCredentialsProvider ; import com.amazonaws.auth.BasicAWSCredentials ; import com.amazonaws.client.builder.AwsClientBuilder ; import com.amazonaws.regions.Regions ; import com.amazonaws.services.s3.AmazonS3 ; import com.amazonaws.services.s3.AmazonS3ClientBuilder ; @Configuration public class Config { @Bean public AmazonS3 s3 () { AWSCredentials credentials = new BasicAWSCredentials( "xxxd20f819xxxxxxxxx2fa6268edxxx" , "yyyyy8e369zzzzzzzzz2b2f52tttttt" ) ; ClientConfiguration clientConfig ...

Get the path of the script

ref:   https://developpaper.com/bash-tips-01-get-the-scripts-own-path/ my_path = $ ( cd $ ( dirname "BASH_SOURCE[0]" ) && pwd ) https://www.ostricher.com/2014/10/the-right-way-to-get-the-directory-of-a-bash-script/ itamar@legolas ~ $  cat foo.sh echo "$0" SCRIPT_DIR= "$( cd " $(  dirname "$0" ) " && pwd )" echo "$SCRIPT_DIR" itamar@legolas ~ $ . /foo .sh . /foo .sh /Users/itamar itamar@legolas ~ $  cd foobar/ itamar@legolas foobar $ ./.. /foo .sh ./.. /foo .sh /Users/itamar

Kill process in CentOS or linux

kill -9 pid ps -ef nohup python main.py &

Install ingress nginx controller

  1. helm repo add stable https://charts.helm.sh/stable 2. kubectl create namespace ingress-nginx 3. helm install -n ingress-nginx ingress-controller \ --set rbac.create=true,\ controller.service.externalTrafficPolicy="Local",\ controller.service.nodePorts.http=30080,\ controller.replicaCount=3 \ stable/nginx-ingress

Gradle build is so slow in docker

Before FROM gradle:6.2.1-jdk11 RUN gradle --version && java -version WORKDIR /app COPY ./ /app/ RUN gradle clean build --no-daemon CMD java -jar build/libs/*.jar   AFTER FROM gradle:6.2.1-jdk11 RUN gradle --version && java -version WORKDIR /app # Only copy dependency-related files COPY build.gradle gradle.properties settings.gradle /app/ # Only download dependencies # Eat the expected build failure since no source code has been copied yet RUN gradle clean build --no-daemon > /dev/null 2>&1 || true # Copy all files COPY ./ /app/ # Do the actual build RUN gradle clean build --no-daemon CMD java -jar build/libs/*.jar

Set up git remote

git remote remove origin git remote -v git remote add origin https://[nguyen.huy.bo]:[access_token]@git.google.com/repo/p.git