- We would like to know how to implement user-data to be used for worker/controller bootstrapping.
- We would like to execute some scripts at worker/controller bootstrapping.
- CloudBees Jenkins Enterprise - AWS/OpenStack
If your CJE is not initialised
the cluster-init operation is performed the file CJE_INSTALLATION/share/setup-templates/core/scripts/cloud-config.yaml is copied to your project to init your cluster, so you will have to edit the ./share/setup-templates/core/scripts/cloud-config.yaml with your modifications before execute the cluster-init operation, then run the cluster-init, after that you could manage other modifications that you want to make on it on .dna/scripts/cloud-config.yaml. That file is the template used to create all project and could change with the version of CJE.
If Your CJE is already initialised
You have a file inside the project folder .dna/scripts/cloud-config.yaml, you can edit it to add new commands to your workers/controllers bootstrapping.
How to add command to cloud-config.yaml file
you could add some commands to the runcmd section.
#cloud-config # vim: syntax=yaml # # This is the configuration syntax that the write_files module # will know how to understand. encoding can be given b64 or gzip or (gz+b64). # The content will be decoded accordingly and then written to the path that is # provided. # # Note: Content strings here are truncated for example purposes. # write_files: # - content: curl # owner: root:root # path: /etc/jce/availability-zone # run commands # default: none # runcmd contains a list of either lists or a string # each item will be executed in order at rc.local like level with # output to the console # - runcmd only runs during the first boot # - if the item is a list, the items will be properly executed as if # passed to execve(3) (with the first arg as the command). # - if the item is a string, it will be simply written to the file and # will be interpreted by 'sh' # # Note, that the list has to be proper yaml, so you have to quote # any characters yaml would eat (':' can be problematic) runcmd: - curl -sSf --create-dirs -o /etc/jce/availability-zone http://169.254.169.254/latest/meta-data/placement/availability-zone - chmod 755 /etc/jce - myNewScriptAtbootstrapping.sh arguments write_files: - path: /etc/sudoers.d/999-cloud-init-requiretty permissions: 440 content: | Defaults:root !requiretty Defaults:centos !requiretty