import re


def make_write_file_block(content:str, outname:str, directory:str='/usr/local/etc/ehos/'):
    """ makes a yaml write_file content block 
    
    Args:
      content: what to enter as content into the block
      outname: the filename the yaml points to
      directory: the directory the yaml points to

    Returns
      write_file block for a yaml file (str)

    Raises:
      None    

    """

    block = """-   content: |
{content}
    path: {filepath}
    owner: root:root
    permissions: '0644'
"""

    # pad the write_file_block with 8 whitespaces to ensure yaml integrity
    content = re.sub("\n", "\n        ", "        "+content)

    
    block = re.sub('{filepath}', "{}/{}".format(directory, outname), block)
    block = re.sub('{content}', "{}".format(content), block)

    return block