Skip to content

Instantly share code, notes, and snippets.

@xphyr
Last active October 14, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xphyr/80efc4fa7952c6716e99d4607a447100 to your computer and use it in GitHub Desktop.
Save xphyr/80efc4fa7952c6716e99d4607a447100 to your computer and use it in GitHub Desktop.
Editing a yaml file with cpu
# This file will handle all the paychex specific edits to openshift config files
# # This file updates the following information
# # turns on emptydir quotas on compute nodes
- hosts: nodes
tasks:
- name: Update Compute Node EmptyDir quota settings
lineinfile: dest=/etc/origin/node/node-config.yaml
backup="yes"
regexp='^ perFSGroup:'
state=present
line=" perFSGroup{{ ":" }} 2Gi"
register: nodeConfig
when:
- openshift_node_labels is defined
- openshift_node_labels.type == 'compute'
- name: Update compute and Infrastructure node system reservations step1
lineinfile: dest=/etc/origin/node/node-config.yaml
backup="yes"
insertafter='kubeletArguments:'
line={{item}}
with_items:
## this is what is giving me issues
## what I want is the 4 lines below added after "kubletArguments:"
### kube-reserved:
### - "cpu=150m,memory=1G"
### system-reserved:
### - "cpu=150m,memory=1G"
- 'kube-reserved{{ ":" }} "cpu=150m,memory=1G"'
- 'system-reserved{{ ":" }} "cpu=150m,memory=1G"'
register: nodeConfig
@m0nkey-br4in
Copy link

Maybe try to use blockinfile like this:

blockinfile: 
  dest:         /etc/origin/node/node-config.yaml
  backup:       'yes'
  insertafter:  'kubeletArguments:'
  block: |
    kube-reserved:
      - "cpu={{ cpu }},memory={{ ram }}"
    system-reserved:
      - "cpu={{ cpu }},memory={{ ram }}"
  register:     nodeConfig

@xphyr
Copy link
Author

xphyr commented Oct 14, 2016

@m0nkey-br4in thanks, unfortunately we are running v1.9 of ansible, and blockinfile is not available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment