LFCS · Question #217
What is the syntax error in the following simple Puppet configuration file? class test_class { file { "/tmp/test.txt": mode => 600, owner => root, group => root } } # Define the node node testclient…
The correct answer is D. isa should be include. The Puppet configuration has a syntax error because it uses isa to include a class in a node definition, where the correct keyword should be include.
Question
Options
- AComments begin with // character and not a #.
- BThe colon (:) after /tmp/test.txt should be a semicolon (;).
- Cclass, node and file sections require a semicolon (;) at the end of their definitions.
- Disa should be include.
How the community answered
(37 responses)- A3% (1)
- C3% (1)
- D95% (35)
Why each option
The Puppet configuration has a syntax error because it uses `isa` to include a class in a node definition, where the correct keyword should be `include`.
Comments in Puppet correctly begin with a hash symbol (#), as shown in the example, so this is not a syntax error.
In Puppet resource declarations, a colon (:) correctly separates the resource title from its attribute list, such as `"/tmp/test.txt":`, so a semicolon (;) would be incorrect here.
Class, node, and resource definitions in Puppet use curly braces ({}) for block delimitation and do not require semicolons (;) at the end of their definitions.
To declare or include a class within a node definition in Puppet, the correct keyword to use is `include` (e.g., `include test_class`), not `isa`, which is not a valid Puppet keyword for this purpose.
Concept tested: Puppet class inclusion syntax
Source: https://www.puppet.com/docs/puppet/7/lang_classes.html
Topics
Community Discussion
No community discussion yet for this question.