A beginners guide to programming and automating stuff

Puppet – Using AWS web console as Puppet’s external node classifier (ENC)

This is a script I wrote that queries the ec2 tags of an aws console, in order to figure out what environment a node belongs to, and what class to assign to it. #!/bin/bash # # export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxx export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxx export AWS_DEFAULT_REGION=xxxxxxx instanceid=`echo $1 | awk -F”_” ‘{print . . . Read more

Puppet – querying puppetdb with postgres command line, psql

Exported Resources querying puppetdb with postgres command line, psql psql -h localhost -U puppetdb puppetdb However to connect to puppet enterprise’s puppetdb, then follow: \q \h \l \d select * FROM catalog_resources \X \x SELECT * FROM catalog_resourcesSELECT * FROM factsselect * from factsssselect * from reports . . . Read more

AWS – SSL termination on the ELB   Terminating SSL using Amazon ELB In my case I replaced: !/elbcheck.html with: ^(.*)$

RHCE – Network Teaming

Link Aggregation In RHEL/CentOS it is possible to combine two (physical or virtual) network interfaces so that they act as one. Having 2 network interfaces acting as one is referred to as link aggregation. There’s 2 advantages to setting up link aggregations: Improved redundancy – i.e. one interface is active, and . . . Read more

RHCE – The getent command

The getent command essentially queries a collection of sources to return a comprehensive list. $ get passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-bus-proxy:x:999:998:systemd Bus Proxy:/:/sbin/nologin systemd-network:x:998:997:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:997:996:User for polkitd:/:/sbin/nologin sssd:x:996:995:User for sssd:/:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin . . …etc . . . Read more

Python – Pip To install python on centos: $ yum install python-pip Some useful commands: $ pip list # equivalent to: yum list aailable … $ pip show {packagename} # equivalent to: yum info …. $ pip search {keyworld} # equivalent to: yum search …. # equivalent to In Ruby, . . . Read more

Python – Virtualenv

Virtualenv is the ruby equialent of ruby’s rbm. To start using Virtualenv, you need to run the following as the root user: $ yum install python-pip $ pip install virtualenv $ pip install virtualenvwrapper # optional but provides the workon From this point forward you can run all other commands . . . Read more

Python – crash course

To install python: $ yum install python indentation is important, since code blocks are not encased in any brackets whatsoever. to access python command line (aka repl) do: [root@ansibleclient01 ~]# python Python 2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2 Type “help”, “copyright”, “credits” . . . Read more