@@ -496,8 +496,8 @@ playbook:
496496 sudo: false
497497 tasks:
498498 - name: OS-specific Task
499- command: echo "Running on {{ .puppet_facts.os.name}}"
500- when: "{{ .puppet_facts.os.family}} == RedHat"
499+ command: echo "Running on {% raw %}{{ .puppet_facts.os.name}}{% endraw % }"
500+ when: "{% raw %}{{ .puppet_facts.os.family}} == RedHat{% endraw %} "
501501` ` `
502502
503503# ### Collector Configuration
@@ -517,26 +517,26 @@ Facts are available as variables in your tasks, using the collector name as the
517517# #### Basic Usage
518518` ` ` yaml
519519- name: Show OS Information
520- command: echo "Running on {{ .puppet_facts.os.name}} {{.puppet_facts.os.release.full}}"
520+ command: echo "Running on {% raw %}{{ .puppet_facts.os.name}} {{.puppet_facts.os.release.full}}{% endraw % }"
521521` ` `
522522
523523# #### Conditional Execution
524524` ` ` yaml
525525- name: Debian-specific Task
526526 command: apt-get update
527- when: "{{ .puppet_facts.os.family}} == Debian"
527+ when: "{% raw %}{{ .puppet_facts.os.family}} == Debian{% endraw %} "
528528
529529- name: RedHat-specific Task
530530 command: yum update
531- when: "{{ .puppet_facts.os.family}} == RedHat"
531+ when: "{% raw %}{{ .puppet_facts.os.family}} == RedHat{% endraw %} "
532532` ` `
533533
534534# #### Nested Facts
535535
536536Facts can have nested structures, which can be accessed using dot notation :
537537` ` ` yaml
538538- name: Show Memory Information
539- command: echo "Total memory: {{ .puppet_facts.memory.system.total}}"
539+ command: echo "Total memory: {% raw %}{{ .puppet_facts.memory.system.total}}{% endraw % }"
540540` ` `
541541
542542# ### Using Puppet Facter
@@ -609,11 +609,11 @@ facts:
609609Access the facts in your tasks :
610610` ` ` yaml
611611- name: Show Application Status
612- command: echo "App version {{ .app_status.version}} is {{.app_status.status}}"
612+ command: echo "App version {% raw %}{{ .app_status.version}} is {{.app_status.status}}{% endraw % }"
613613
614614- name: Restart if Connections Too High
615615 command: systemctl restart myapp
616- when: "{{ .app_status.connections}} > 100"
616+ when: "{% raw %}{{ .app_status.connections}}{% endraw % } > 100"
617617` ` `
618618
619619# ### Troubleshooting
@@ -640,7 +640,7 @@ If jq reports errors, your JSON is not valid.
640640
641641If you have complex nested facts, you can use the dot notation to access nested values :
642642` ` `
643- {{ .puppet_facts.networking.interfaces.eth0.ip}}
643+ {% raw %}{{ .puppet_facts.networking.interfaces.eth0.ip}}{% endraw % }
644644` ` `
645645
646646# ### Examples
@@ -664,7 +664,7 @@ playbook:
664664 sudo: true
665665 tasks:
666666 - name: Show System Information
667- command: echo "Host: {{ .system.networking.hostname}}, OS: {{.system.os.name}} {{.system.os.release.full}}, CPU: {{.system.processors.models.0}}, RAM: {{.system.memory.system.total}}"
667+ command: echo "Host: {% raw %}{{ .system.networking.hostname}}, OS: {{.system.os.name}} {{.system.os.release.full}}, CPU: {{.system.processors.models.0}}, RAM: {{.system.memory.system.total}}{% endraw % }"
668668` ` `
669669
670670# #### OS-Specific Deployment
@@ -690,12 +690,12 @@ playbook:
690690 - name: Install Dependencies (Debian)
691691 command: apt-get install -y nginx nodejs
692692 sudo: true
693- when: "{{ .os_info.os.family}} == Debian"
693+ when: "{% raw %}{{ .os_info.os.family}}{% endraw % } == Debian"
694694
695695 - name: Install Dependencies (RedHat)
696696 command: yum install -y nginx nodejs
697697 sudo: true
698- when: "{{ .os_info.os.family}} == RedHat"
698+ when: "{% raw %}{{ .os_info.os.family}}{% endraw % } == RedHat"
699699
700700 - name: Deploy Application
701701 command: /usr/local/bin/deploy.sh
@@ -757,6 +757,31 @@ groups:
757757 hosts: [...]
758758` ` `
759759
760+ # ## Task Group Restrictions
761+
762+ Restrict tasks to specific groups :
763+ ` ` ` yaml
764+ tasks:
765+ - name: Database Backup
766+ command: /usr/local/bin/backup-db.sh
767+ sudo: true
768+ only_groups: [database]
769+
770+ - name: Web Server Config
771+ command: /etc/nginx/sites-available/default
772+ sudo: true
773+ only_groups: [webserver]
774+
775+ - name: Update All Servers
776+ command: apt-get update
777+ sudo: true
778+ # No only_groups, runs on all hosts
779+
780+ - name: Test Environment Only
781+ command: /usr/local/bin/test-feature.sh
782+ skip_groups: [production]
783+ ` ` `
784+
760785# ## Retries and Error Handling
761786` ` ` yaml
762787tasks:
0 commit comments