puppetdb query

[mshaik@puppetdb ~]$ curl -X GET http://localhost:8080/v3/facts/swapsize --data-urlencode 'query=["=", "value", "0.00 MB"]' [ { "value" : "0.00 MB", "name" : "swapsize", "certname" : "elk.c.rich-operand-154505.internal" } ] [root@puppetdb ~]# curl -X GET http://localhost:8080/v3/facts/role/puppetdb [ { "value" : "puppetdb", "name" : "role", "certname" : "puppetdb.puppethub.in" } ] [root@puppetdb ~]# curl -X GET http://localhost:8080/v3/facts/role --data-urlencode 'query=["=", "value", "puppetdb"]' [ … Continue reading puppetdb query

puppetdb(postgres)

[root@puppetdb ~]# sudo -u postgres psql postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | UTF8 | en_IN | en_IN | puppetdb | postgres | UTF8 | en_IN | en_IN | =T/postgres + | | | | | postgres=CTc/postgres+ | | | … Continue reading puppetdb(postgres)

Ansible tower

[root@tower ~]# wget http://releases.ansible.com/ansible-tower/setup/ansible-tower-setup-latest.tar.gz --2017-01-30 20:46:20-- http://releases.ansible.com/ansible-tower/setup/ansible-tower-setup-latest.tar.gz Resolving releases.ansible.com (releases.ansible.com)... 104.24.17.59, 104.24.16.59, 2400:cb00:2048:1::6818:103b, ... Connecting to releases.ansible.com (releases.ansible.com)|104.24.17.59|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 737047 (720K) [application/x-gzip] Saving to: ‘ansible-tower-setup-latest.tar.gz’ 100%[======================================================================================================>] 7,37,047 3.47MB/s in 0.2s 2017-01-30 20:46:20 (3.47 MB/s) - ‘ansible-tower-setup-latest.tar.gz’ saved [737047/737047] [root@tower ~]# ls -l total 720 -rw-r--r--. 1 root … Continue reading Ansible tower

including variables in Ansible

===================================== [mohammedrafi@ansible1 ~]$ mkdir nginx ===================================== [mohammedrafi@ansible1 ~]$ cd nginx [mohammedrafi@ansible1 nginx]$ mkdir tasks vars ===================================== [mohammedrafi@ansible1 nginx]$ touch tasks/environment.yml ===================================== [mohammedrafi@ansible1 nginx]$ touch vars/variables.yml ===================================== [mohammedrafi@ansible1 ~]$ tree nginx nginx |-- nginx.yml |-- tasks | `-- environment.yml `-- vars `-- variables.yml ===================================== [mohammedrafi@ansible1 nginx]$ vim tasks/environment.yml --- - name: install package yum: name: "{{ package … Continue reading including variables in Ansible

creating role in ansible

Creating a basic role for displaying message of the day  [root@workstation ~]# vim /etc/ansible/roles/motd/main.yml --- - name: use motd role playbook hosts: all roles: - motd [root@workstation ~]# vim /etc/ansible/roles/motd/defaults/main.yml --- system_owner: mohammedrafi [root@workstation ~]# vim /etc/ansible/roles/motd/tasks/main.yml --- - name: deliver motd file template: src: templates/motd.j2 dest: /etc/motd owner: root group: root mode: 777 [root@workstation ~]# vim /etc/ansible/roles/motd/templates/motd.j2 this … Continue reading creating role in ansible

tags in ansible

[root@workstation ~]# vim tags.yaml --- - name: installing postfix and stopping from starting service hosts: localhost tasks: - name: installing postfix package yum: name=postfix state=latest tags: packageonly - name: starting service service: name=postfix state=started [root@workstation ~]# ansible-playbook --syntax-check tags.yaml playbook: tags.yaml [root@workstation ~]# ansible-playbook -C tags.yaml PLAY [installing postfix and stopping from starting service] ******************* … Continue reading tags in ansible

handlers & register in ansible

[root@workstation ~]# vim register.yaml --- - name: checking the register module functionality hosts: localhost tasks: - name: command: ps register: output - debug: msg="{{ output.stdout }}" ==================================================== [root@workstation ~]# ansible-playbook --syntax-check register.yaml playbook: register.yaml [root@workstation ~]# ansible-playbook register.yaml PLAY [checking the register module functionality] ****************************** TASK [setup] ******************************************************************* ok: [localhost] TASK [command] ***************************************************************** changed: [localhost] … Continue reading handlers & register in ansible

JINJA2 templates in ansible

[root@workstation ~]# ansible -m ping all 192.168.183.129 | SUCCESS => { "changed": false, "ping": "pong" } 192.168.183.128 | SUCCESS => { "changed": false, "ping": "pong" } ========================================= [root@workstation ~]# vim motd.j2 this is {{ ansible_hostname }}. today's date is {{ ansible_date_time.date }} you can ask {{ system_owner }} for access ========================================== [root@workstation ~]# vim motd.yaml … Continue reading JINJA2 templates in ansible

ansible vault

[root@workstation ~]# ansible-vault create rafi.yml Vault password: [root@workstation ~]# cat rafi.yml $ANSIBLE_VAULT;1.1;AES256 38623235633039636166356162393064363936303461306536386237663032383932656164633131 6132633132376266313863366164396535386539666562310a306562383834343431633536353332 63303935623030393261373030343366323361653238306531356434333538613236303738653730 3935313536396361640a343836366434613638316538333165366161306166396564353635383831 30636536366462646362373432396234383432376437633764616239393938366137 [root@workstation ~]# ansible-vault view rafi.yml Vault password: hai how are you [root@workstation ~]# ansible-vault edit rafi.yml Vault password: [root@workstation ~]# ansible-vault rekey rafi.yml Vault password: New Vault password: Confirm New Vault password: Rekey successful [root@workstation ~]# ansible-playbook rafi.yml … Continue reading ansible vault

Managing files in ansible

[mshaik@workstation ~]$ ansible localhost --list-hosts hosts (1): localhost ------------------------------------------- [mshaik@workstation ~]$ vim file.yaml --- - name: creating a file hosts: localhost tasks: - file: path: /home/mshaik/sample state: touch owner: mshaik group: mshaik mode: 0755 ... ------------------------------------------- [mshaik@workstation ~]$ ansible-playbook --syntax-check file.yaml playbook: file.yaml ---------------------------------------- [mshaik@workstation ~]$ ansible-playbook -C file.yaml PLAY [creating a file] ********************************************************* TASK … Continue reading Managing files in ansible