Puppet examples

Saturday, November 21, 2015

Class definition through creating text files




kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /etc/puppet/manifests/class-definition-example.pp
class australianstates {
    define australianstates ($data) {
      file {"$title":
        ensure  => file,
        content => $data,
      }
    }

    australianstates {'/tmp/Queensland':
      data => "The name of the state is Queensland and the biggest city in Queensland is Brisbane.\n",
    }

    australianstates {'/tmp/Western-Australia':
      data => "The name of the state is Western Australia and the biggest city in Western Australia is Perth.\n",
    }

    australianstates {'/tmp/Victoria':
      data => "The name of the state is Victoria and the biggest city in Victoria is Melbourne.\n",
    }

    australianstates {'/tmp/New-South-Wales':
      data => "The name of the state is New South Wales and the biggest city in New South Wales is Sydney.\n",
    }

    australianstates {'/tmp/South-Australia':
      data => "The name of the state is South Australia and the biggest city in South Australia is Adelaide.\n",
    }

}

include australianstates
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > ls -altr /tmp
total 40
-rw-r--rwx   1 root root    44 Nov 15 14:44 MCG-greeting
dr-xr-xr-x. 39 root root  4096 Nov 18 14:00 ..
drwxrwxrwt.  3 root root  4096 Nov 18 16:09 .
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > puppet apply /etc/puppet/manifests/class-definition-example.pp
Fact file /etc/puppet/modules/team_custom_facts/facts.d/README was parsed but returned an empty data set
Notice: Compiled catalog for kirandspuppet.eng.company.com in environment production in 0.11 seconds
Notice: /Stage[main]/Australianstates/Australianstates::Australianstates[/tmp/South-Australia]/File[/tmp/South-Australia]/ensure: defined content as '{md5}b7e373d27545394f8e4732e85ebaadd4'
Notice: /Stage[main]/Australianstates/Australianstates::Australianstates[/tmp/Western-Australia]/File[/tmp/Western-Australia]/ensure: defined content as '{md5}4003cf6adc7ffa2994d75a41eb8194c6'
Notice: /Stage[main]/Australianstates/Australianstates::Australianstates[/tmp/New-South-Wales]/File[/tmp/New-South-Wales]/ensure: defined content as '{md5}0b3930b482c945847148c6a0c004e56c'
Notice: /Stage[main]/Australianstates/Australianstates::Australianstates[/tmp/Queensland]/File[/tmp/Queensland]/ensure: defined content as '{md5}cec0f13e296a213b16c85e22b955fd08'
Notice: /Stage[main]/Australianstates/Australianstates::Australianstates[/tmp/Victoria]/File[/tmp/Victoria]/ensure: defined content as '{md5}a36380ab3f7e05ec4f0d83c1da638b31'
Notice: Finished catalog run in 0.07 seconds
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > ls -altr /tmp
total 60
-rw-r--rwx   1 root root    44 Nov 15 14:44 MCG-greeting
dr-xr-xr-x. 39 root root  4096 Nov 18 14:00 ..
-rw-r--r--   1 root root    94 Nov 18 16:10 South-Australia
-rw-r--r--   1 root root    95 Nov 18 16:10 Western-Australia
-rw-r--r--   1 root root    92 Nov 18 16:10 New-South-Wales
-rw-r--r--   1 root root    84 Nov 18 16:10 Queensland
-rw-r--r--   1 root root    81 Nov 18 16:10 Victoria
drwxrwxrwt.  3 root root  4096 Nov 18 16:10 .
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /tmp/South-Australia
The name of the state is South Australia and the biggest city in South Australia is Adelaide.
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /tmp/Western-Australia
The name of the state is Western Australia and the biggest city in Western Australia is Perth.
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /tmp/New-South-Wales
The name of the state is New South Wales and the biggest city in New South Wales is Sydney.
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /tmp/Queensland
The name of the state is Queensland and the biggest city in Queensland is Brisbane.
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / > cat /tmp/Victoria
The name of the state is Victoria and the biggest city in Victoria is Melbourne.
kirandspuppet: / >
kirandspuppet: / >
kirandspuppet: / >

No comments:

Post a Comment