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