Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [dwfox@lin-w540 ansible-repo]$ ansible-playbook local.yml -kKCD -u davidf1 -c ssh --limit="durgzone27-dev" -t ntpd
- SSH password:
- sudo password [defaults to SSH password]:
- PLAY [!ng*:testing:subprod:c1nagios] ******************************************
- GATHERING FACTS ***************************************************************
- ok: [durgzone27-dev]
- TASK: [ntpd | group_by key={{ ansible_distribution }}] ************************
- ok: [durgzone27-dev]
- TASK: [ntpd | group_by key=net_{{ ansible_default_ipv4.network }}] ************
- ok: [durgzone27-dev]
- TASK: [ntpd | debug hostvars] *************************************************
- skipping: [durgzone27-dev]
- TASK: [ntpd | enable ntp service] *********************************************
- failed: [durgzone27-dev] => {"failed": true}
- msg: svcs: Pattern 'ntpd' doesn't match any instances
- FATAL: all hosts have already failed -- aborting
- PLAY RECAP ********************************************************************
- to retry, use: --limit @/home/dwfox/local.retry
- durgzone27-dev : ok=3 changed=0 unreachable=0 failed=1
- [dwfox@lin-w540 ansible-repo]$ more roles/ntpd/tasks/ntpd.yml
- ---
- ## Let's create a group dynamically, by OS ##
- - group_by: key={{ ansible_distribution }}
- changed_when: False
- ## Let's greate a group dynamically, by subnet ##
- - group_by: key=net_{{ ansible_default_ipv4.network }}
- changed_when: False
- - name: debug hostvars
- debug: var=hostvars[inventory_hostname]
- when: debug is defined
- ## Ensure the ntp service is started ##
- - name: "enable ntp service"
- service: name={{ ntpservice }} state=started
- ## configure ntpd, restart if change is made ##
- - name: "put ntp.conf in place"
- template: src=ntp.conf.j2 dest={{ ntpconf }} owner=root group={{ root_group }} mode=0644 backup=yes
- notify:
- - restart ntpd
- [dwfox@lin-w540 ansible-repo]$ ansible durgzone27-dev -m setup -kK -a 'filter=ansible_distribution' -u davidf1
- SSH password:
- sudo password [defaults to SSH password]:
- durgzone27-dev | success >> {
- "ansible_facts": {
- "ansible_distribution": "Solaris"
- },
- "changed": false
- }
- [dwfox@lin-w540 ansible-repo]$ cat group_vars/Solaris
- ---
- ntpconf: /etc/inet/ntp.conf
- ntpservice: ntp
- sshdservice: ssh
- [dwfox@lin-w540 ansible-repo]$ grep ntpservice group_vars/all
- ntpservice: ntpd
- [dwfox@lin-w540 ansible-repo]$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement