Rending problem in file.blockreplace

40 views
Skip to first unread message

Arvind Sharma

unread,
Jan 29, 2015, 9:23:19 AM1/29/15
to salt-...@googlegroups.com
Hi All ,

I am new to salt stack as well as community ,

I am using file.blockreplace to manage a php file which basically have global config files .

config_injection:
  file.blockreplace:
    - name: /tmp/config.local.php
    - marker_start: "# START managed zone injection"
    - marker_end: "# END managed zone injection"
    - content: "$config['block_injection']=array("'","\"","'",'"','--');"
    - append_if_not_found: True
    - backup: '.bak'
    - show_changes: True

after executing salt '*' state.highstate i am getting error

clinet1:
    Data failed to compile:
----------
    Rendering SLS block_replace failed, render error: while parsing a block mapping
  in "<unicode string>", line 34, column 7:
        - content: "$config['block_injecti ... 
          ^
expected <block end>, but found '<scalar>'
  in "<unicode string>", line 34, column 59:
     ... lock_injection']=array("'","\"","'",'"','--'...... 
                     ^
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 2408, in render_state
    sls, rendered_sls=mods
  File "/usr/lib/python2.6/site-packages/salt/template.py", line 84, in compile_template
    ret = render(input_data, saltenv, sls, **render_kwargs)
  File "/usr/lib/python2.6/site-packages/salt/renderers/yaml.py", line 48, in render
    data = load(yaml_data, Loader=get_yaml_loader(argline))
  File "/usr/lib64/python2.6/site-packages/yaml/__init__.py", line 71, in load
    return loader.get_single_data()
  File "/usr/lib64/python2.6/site-packages/yaml/constructor.py", line 37, in get_single_data
    node = self.get_single_node()
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib64/python2.6/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib64/python2.6/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib64/python2.6/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key
    "expected <block end>, but found %r" % token.id, token.start_mark)
ParserError: while parsing a block mapping
  in "<unicode string>", line 34, column 7:
        - content: "$config['block_injecti ... 
          ^
expected <block end>, but found '<scalar>'
  in "<unicode string>", line 34, column 59:
     ... lock_injection']=array("'","\"","'",'"','--'......
                     ^


Sorry if This thread is repeated , 

Thanks & Regards
Arvind
Devops Engg.
Shopclues

Alan Garfield

unread,
Jan 29, 2015, 3:10:28 PM1/29/15
to salt-...@googlegroups.com
Might be all the double quotes etc fouling up the outside double quote block you've got?!

Try this instead, I always find this easier to read too:

file.blockreplace:
    - name: /tmp/config.local.php
    - marker_start: "# START managed zone injection"
    - marker_end: "# END managed zone injection"
    - content: |
         $config['block_injection']=array("'","\"","'",'"','--');
    - append_if_not_found: True
    - backup: '.bak'
    - show_changes: True

-A.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arvind Sharma

unread,
Jan 29, 2015, 10:52:53 PM1/29/15
to salt-...@googlegroups.com

Thanks Alan thanks a lot , magically ur solution worked .

Reply all
Reply to author
Forward
0 new messages