Custom Search

Saturday, November 24, 2018

How to Visualize Puppet manifest Resources and Relationships

#sudo /usr/bin/puppet apply --verbose --debug --trace --modulepath /usr/share/puppet/modules:/usr/share/openstack-puppet/modules /etc/puppet/manifests/bootstrap.pp —noop —graph




sudo ls /var/lib/puppet/state/graphs/

#brew install graphviz
#yum -y install graphviz
#apt-get -y install graphviz

dot -Tpdf myfile.dot -o myfile.pdf

Sunday, November 18, 2018

How to Remove old Docker Containers

#sudo docker ps -qa
#sudo docker ps -q
#sudo docker rm --force `docker ps -qa`

#sudo docker ps -a | awk '/myimage/{print $1}'
#sudo docker rm  $(docker ps -a | awk '/myimage/{print $1}')

What is the difference between the `COPY` and `ADD` commands in a Dockerfile

$ vim Dockerfile

FROM centos:7.4.1708

RUN mkdir /mydata

COPY myfiles /mydata/myfiles

ADD myfiles2 /mydata/myfile2

ADD https://files.pythonhosted.org/packages/45/ae/8a0ad77defb7cc903f09e551d88b443304a9bd6e6f124e75c0fbbf6de8f7/pip-18.1.tar.gz /mydata

ADD pip-18.1.tar.gz /mydata/pipunpack

======================

sudo docker build -t myimage1 .

sudo docker run -itd --name mycontainer myimage1

sudo docker ps

sudo docker exec -it e89db4565fea /bin/bash

Saturday, November 17, 2018

What is the difference between CMD and ENTRYPOINT in a Dockerfile

a)
without entrypoint:
sudo docker run --rm myimage /bin/ls dev
sudo docker run --rm myimage /bin/ls var

b)
with entrypoint:
sudo docker run --rm --entrypoint="/bin/ls" myimage dev
sudo docker run --rm --entrypoint="/bin/ls" myimage var

c)
with entrypoint in Dockerfile:
# Dockerfile
FROM centos:7.4.1708
ENTRYPOINT ["/bin/ls"]

sudo docker build -t myimage1 .


sudo docker run --rm myimage1 dev
sudo docker run --rm myimage1 /bin/ls dev

d)
with entrypoint in Dockerfile:
# Dockerfile
FROM centos:7.4.1708
CMD dev
ENTRYPOINT ["/bin/ls"]

sudo docker build -t myimage1 .

sudo docker run --rm myimage1

Sunday, November 4, 2018

Python ElasticSearch How to get cluster health

from elasticsearch import Elasticsearch

HOST_URLS = ["http://127.0.0.1:9200"]
es_conn = Elasticsearch(HOST_URLS)


es_conn.cluster.health()

{u'status': u'yellow', u'number_of_nodes': 1, u'unassigned_shards': 5, u'number_of_pending_tasks': 0, u'number_of_in_flight_fetch': 0, u'timed_out': False, u'active_primary_shards': 6, u'task_max_waiting_in_queue_millis': 0, u'cluster_name': u'elasticsearch', u'relocating_shards': 0, u'active_shards_percent_as_number': 54.54545454545454, u'active_shards': 6, u'initializing_shards': 0, u'number_of_data_nodes': 1, u'delayed_unassigned_shards': 0}

http://127.0.0.1:9200/_cluster/health




Python Elasticsearch API find cluster name

sudo pip install elasticsearch

from elasticsearch import Elasticsearch
HOST_URLS = ["http://127.0.0.1:9200"]
es_conn = Elasticsearch(HOST_URLS)

print "Cluster Name: ", es_conn.cluster.state(metric=["cluster_name"])['cluster_name']

How to get a list of all indexes in python-elasticsearch

sudo pip install elasticsearch

from elasticsearch import Elasticsearch
HOST_URLS = ["http://127.0.0.1:9200"]
es_conn = Elasticsearch(HOST_URLS)
es_conn.indices.get_alias()
es_conn.indices.get_mapping().keys()

http://127.0.0.1:9200/_alias
http://127.0.0.1:9200/_mapping