Difference between revisions of "Ansible Operations"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(Provide In-Line Prompt Confirmation)
 
(One intermediate revision by the same user not shown)
Line 26: Line 26:
  
 
{{Internal|ansible-playbook|ansible-playbook}}
 
{{Internal|ansible-playbook|ansible-playbook}}
 +
 +
=Provide In-Line Prompt Confirmation=
 +
 +
ansible-playbook ... -e reset_confirmation=yes
 +
 +
where "reset_confirmation" is defined in playbook:
 +
 +
- hosts: etcd:k8s-cluster:calico-rr
 +
 +
  pre_tasks:
 +
    - name: check confirmation
 +
      fail:
 +
        msg: "Reset confirmation failed"
 +
      when: reset_confirmation != "yes"

Latest revision as of 22:22, 4 December 2019

Internal

Ping all Hosts from a Group

This will also list the hosts from that group.

ansible all -m ping

Execute a Shell Command on all Hosts in Some Groups

ansible masters,nodes -m shell -a "systemctl status docker | grep Active"

Copy Files

ansible <my-servers> -m copy -a "src=/root/ipa-ca.crt dest=/etc/origin/master"

ansible-playbook

ansible-playbook

Provide In-Line Prompt Confirmation

ansible-playbook ... -e reset_confirmation=yes

where "reset_confirmation" is defined in playbook:

- hosts: etcd:k8s-cluster:calico-rr

  pre_tasks:
    - name: check confirmation
      fail:
        msg: "Reset confirmation failed"
      when: reset_confirmation != "yes"