I have several hundreds YAML files which needs to be updated from time to time. 

Before update: 

```
sss:
  - ccc:
      brr: 'mmm'
      jdk: 'openjdk8'
  - bbb:
      brr: 'rel/bbb'
      jdk: 'openjdk8'
  - aaa:
      brr: 'rel/aaa'
      jdk: 'openjdk7'

```

After update:

```
sss:
  - ddd: 
      brr: 'mmm'
      jdk: 'openjdk8'
  - ccc:
      brr: 'rel/ccc'
      jdk: 'openjdk8'
  - bbb:
      brr: 'rel/bbb'
      jdk: 'openjdk8'
  - aaa:
      brr: 'rel/aaa'
      jdk: 'openjdk7'

```

1. For any occurrence of the following pattern in any file:

> 
> 
> ```
> sss:
>   - ccc:
>       brr: 'mmm'
> 
> ```
> 
> 

2. Substitute and modify the above pattern to replace `'mmm'` with `'rel/ccc'`:

> 
> 
> ```
>   - ccc:
>       brr: 'rel/ccc'
> 
> ```
> 
> 

3. Create new sub-string (multi-lined) in the format:

> 
> 
> ```
>   - new: 
>       brr: 'new-mmm'
>       jdk: 'openjdk8'
> 
> ```
> 
> 

4. Combined 2. and 3. and replace the original file with:

> 
> 
> ```
> sss:
>   - new: 
>       brr: 'mmm'
>       jdk: 'openjdk8'
>   - ccc:
>       brr: 'rel/ccc'
>       jdk: 'openjdk8'
> 
> ```
> 
> 

For instance we need to update the above file to look like preserving the white spaces/tabs in each line, since formatting is important for YAML.

I have already tried this with PyYAML and does not work due to complexities in the syntax. Can this be done by capturing the white spaces using awk, sed ?