项目作者: SpringerPE

项目描述 :
Add-on for ansible-boshrelease to manage Cloud Foundry Organizations, Spaces, Users, Quotas, Security Groups, Environment variables and feature flags
高级语言: Shell
项目地址: git://github.com/SpringerPE/ansible-cfsetup-boshrelease.git
创建时间: 2016-12-07T09:34:37Z
项目社区:https://github.com/SpringerPE/ansible-cfsetup-boshrelease

开源协议:Apache License 2.0

下载


Add-on BOSH Release for ansible-boshrelease

Add-on release with ansible playbooks to manage Cloud Foundry resources:
users, security groups, quotas, feature flags, environment variables, organizations and spaces

The core functionality is provided by https://github.com/SpringerPE/ansible-cloudfoundry-role,
this is just an add-on to run the that ansible role in a Bosh errand.

Usage

This is and add-on release, it will work only if it is deployed together with the
ansible-boshrelease on the nodes, in particular with ansible-deploy job.
Have a look at ansible-boshrelease
for the requirements and to see how it works.

Considering v2 manifest style, this could be an example:

  1. name: cfsetup
  2. # replace with `bosh status --uuid`
  3. director_uuid: 1c799a52-154b-4fb3-b181-d81ec5f3c97b
  4. releases:
  5. - name: ansible
  6. version: latest
  7. - name: ansible-cfsetup
  8. version: latest
  9. stemcells:
  10. - alias: trusty
  11. name: bosh-vsphere-esxi-ubuntu-trusty-go_agent
  12. version: latest
  13. instance_groups:
  14. - name: ansible-cfsetup
  15. lifecycle: errand
  16. instances: 1
  17. vm_type: medium
  18. stemcell: trusty
  19. vm_extensions: []
  20. azs:
  21. - Online
  22. networks:
  23. - name: online
  24. jobs:
  25. - name: ansible-deploy
  26. release: ansible
  27. - name: ansible-cfsetup
  28. release: ansible-cfsetup
  29. properties:
  30. ansible_cfsetup:
  31. credentials:
  32. - name: test
  33. api: "https://api.test.cf.springer-sbm.com"
  34. admin: "admin"
  35. password: "password"
  36. feature_flags:
  37. - name: user_org_creation
  38. value: true
  39. running_environment_variables:
  40. - name: HOLA
  41. value: hola
  42. - name: ADIOS
  43. value: bye
  44. security_groups:
  45. - name: sec1
  46. state: present
  47. context: running
  48. context_state: present
  49. rules:
  50. - name: "allow-proxy"
  51. protocol: tcp
  52. destination: "10.20.0.1/0"
  53. ports: "8080"
  54. quotas:
  55. - name: quota1
  56. state: present
  57. total_services: 100
  58. total_routes: 1000
  59. memory_limit: 1000
  60. users:
  61. - name: pepe@hola.com
  62. state: present
  63. password: hola
  64. given_name: Pepe
  65. family_name: Family
  66. - name: claudio@hola.com
  67. state: present
  68. password: hola
  69. given_name: Claudio
  70. family_name: Family
  71. orgs:
  72. - name: org1
  73. quota: quota1
  74. state: present
  75. users:
  76. - name: pepe@hola.com
  77. managers:
  78. - name: claudio@hola.com
  79. spaces:
  80. - name: test
  81. - name: second
  82. - name: org2
  83. state: present
  84. quota: quota1
  85. spaces:
  86. - name: live
  87. state: present
  88. managers:
  89. - name: claudio@hola.com
  90. security_groups:
  91. - name: sec1
  92. update:
  93. canaries: 1
  94. max_in_flight: 1
  95. serial: false
  96. canary_watch_time: 1000-60000
  97. update_watch_time: 1000-60000

You can add more Cloud Foundry environments in credentials to apply the same
settings to all of them (see also the parallel parameter to control the serialization/parallelism.

and that’s all!, run bosh-deploy. Once the release has been deployed, you can run it as a errand:

  1. # bosh errands
  2. https://10.10.0.10:25555
  3. +-----------------+
  4. | Name |
  5. +-----------------+
  6. | ansible-cfsetup |
  7. +-----------------+

And then run the errand:

  1. # bosh run errand ansible-cfsetup
  2. https://10.10.0.10:25555
  3. Acting as user 'admin' on deployment 'cfsetup' on 'pe-dogo-01'
  4. Director task 2964
  5. Started preparing deployment > Preparing deployment. Done (00:00:00)
  6. Started preparing package compilation > Finding packages to compile. Done (00:00:00)
  7. Started creating missing vms > ansible-cfsetup/26fb59a0-2866-49f6-8644-fcd0e1d85b75 (0). Done (00:02:14)
  8. Started updating instance ansible-cfsetup > ansible-cfsetup/26fb59a0-2866-49f6-8644-fcd0e1d85b75 (0) (canary). Done (00:00:24)
  9. Started running errand > ansible-cfsetup/0. Done (00:00:07)
  10. Started fetching logs for ansible-cfsetup/26fb59a0-2866-49f6-8644-fcd0e1d85b75 (0) > Finding and packing log files. Done (00:00:01)
  11. Started deleting errand instances ansible-cfsetup > ansible-cfsetup/26fb59a0-2866-49f6-8644-fcd0e1d85b75 (0). Done (00:00:18)
  12. Task 2964 done
  13. Started 2016-12-06 23:27:58 UTC
  14. Finished 2016-12-06 23:31:02 UTC
  15. Duration 00:03:04
  16. [stdout]
  17. * 6637: /var/vcap/packages/ansible/bin/ansible-playbook -i /var/vcap/jobs/ansible-cfsetup/ansible/inventory /var/vcap/jobs/ansible-cfsetup/ansible/deploy.yml
  18. PLAY [Cloud Foundry settings playbook] *****************************************
  19. TASK [cf : Check PIP dependencies for ansible modules] *************************
  20. ok: [api.test.cf.springer-sbm.com -> localhost] => (item={'key': u'cfconfigurator', 'value': u'0.2.1'})
  21. TASK [cf : Config - Set global feature flags] **********************************
  22. ok: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'user_org_creation', u'value': True})
  23. TASK [cf : Config - Set global running environment variables group] ************
  24. ok: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'HOLA', u'value': u'hola'})
  25. ok: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'ADIOS', u'value': u'bye'})
  26. TASK [cf : Config - Set global staging environment variables group] ************
  27. TASK [cf : Config - Set global shared domains] *********************************
  28. TASK [cf : Secgroups - Setting global security groups] *************************
  29. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/secgroup.yml for api.test.cf.springer-sbm.com
  30. TASK [cf : Secgroup - Procesing security group sec1] ***************************
  31. ok: [api.test.cf.springer-sbm.com -> localhost]
  32. TASK [cf : Secgroup - Facts] ***************************************************
  33. ok: [api.test.cf.springer-sbm.com -> localhost]
  34. TASK [cf : Secgroup - Managing security group sec1: present] *******************
  35. changed: [api.test.cf.springer-sbm.com -> localhost]
  36. TASK [cf : Secgroup - Setting up security group rules] *************************
  37. changed: [api.test.cf.springer-sbm.com -> localhost] => (item=(0, {u'destination': u'10.20.0.1/0', u'protocol': u'tcp', u'name': u'allow-proxy', u'ports': u'8080'}))
  38. TASK [cf : Secgroup - Managing sec1 in space] **********************************
  39. TASK [cf : Secgroups - Managing default security groups] ***********************
  40. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'rules': [{u'destination': u'10.20.0.1/0', u'protocol': u'tcp', u'name': u'allow-proxy', u'ports': u'8080'}], u'state': u'present', u'name': u'sec1'
  41. , u'context': u'running', u'context_state': u'present'})
  42. TASK [cf : Quotas - Processing quota definitions] ******************************
  43. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'memory_limit': 1000, u'state': u'present', u'total_routes': 1000, u'name': u'quota1', u'total_services': 100})
  44. TASK [cf : Users - Managing users] *********************************************
  45. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'family_name': u'Family', u'state': u'present', u'password': u'hola', u'name': u'pepe@hola.com', u'given_name': u'Pepe'})
  46. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'family_name': u'Family', u'state': u'present', u'password': u'hola', u'name': u'claudio@hola.com', u'given_name': u'Claudio'})
  47. TASK [cf : Orgs - Setting up organizations] ************************************
  48. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/org.yml for api.test.cf.springer-sbm.com
  49. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/org.yml for api.test.cf.springer-sbm.com
  50. TASK [cf : Org - Procesing organization org1] **********************************
  51. ok: [api.test.cf.springer-sbm.com -> localhost]
  52. TASK [cf : Org - Facts] ********************************************************
  53. ok: [api.test.cf.springer-sbm.com -> localhost]
  54. TASK [cf : Org - Defining organization org1] ***********************************
  55. changed: [api.test.cf.springer-sbm.com -> localhost]
  56. TASK [cf : Org - Managing spaces for org1] *************************************
  57. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/space.yml for api.test.cf.springer-sbm.com
  58. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/space.yml for api.test.cf.springer-sbm.com
  59. TASK [cf : Space - Procesing space test in org1 organization] ******************
  60. ok: [api.test.cf.springer-sbm.com -> localhost]
  61. TASK [cf : Space - Facts] ******************************************************
  62. ok: [api.test.cf.springer-sbm.com -> localhost]
  63. TASK [cf : Space - Managing space org1:test present] ***************************
  64. changed: [api.test.cf.springer-sbm.com -> localhost]
  65. TASK [cf : Space - Managing security groups for org1:test] *********************
  66. TASK [cf : Space - Assigning developers to org1:test] **************************
  67. TASK [cf : Space - Assigning managers to space org1:test] **********************
  68. TASK [cf : Space - Assigning auditors to space org1:test] **********************
  69. TASK [cf : Space - Procesing space second in org1 organization] ****************
  70. ok: [api.test.cf.springer-sbm.com -> localhost]
  71. TASK [cf : Space - Facts] ******************************************************
  72. ok: [api.test.cf.springer-sbm.com -> localhost]
  73. TASK [cf : Space - Managing space org1:second present] *************************
  74. changed: [api.test.cf.springer-sbm.com -> localhost]
  75. TASK [cf : Space - Managing security groups for org1:second] *******************
  76. TASK [cf : Space - Assigning developers to org1:second] ************************
  77. TASK [cf : Space - Assigning managers to space org1:second] ********************
  78. TASK [cf : Space - Assigning auditors to space org1:second] ********************
  79. TASK [cf : Org - Deleting spaces for org1] *************************************
  80. TASK [cf : Org - Deleting organization org1] ***********************************
  81. TASK [cf : Org - Create private domains to organization org1] ******************
  82. TASK [cf : Org - Assigning users to organization org1] *************************
  83. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'pepe@hola.com'})
  84. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'claudio@hola.com'})
  85. TASK [cf : Org - Assigning managers to organization org1] **********************
  86. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'claudio@hola.com'})
  87. TASK [cf : Org - Assigning auditors to organization org1] **********************
  88. TASK [cf : Org - Assigning billing_managers to organization org1] **************
  89. TASK [cf : Org - Assigning default organization org1 for requested users] ******
  90. TASK [cf : Org - Procesing organization org2] **********************************
  91. ok: [api.test.cf.springer-sbm.com -> localhost]
  92. TASK [cf : Org - Facts] ********************************************************
  93. ok: [api.test.cf.springer-sbm.com -> localhost]
  94. TASK [cf : Org - Defining organization org2] ***********************************
  95. changed: [api.test.cf.springer-sbm.com -> localhost]
  96. TASK [cf : Org - Managing spaces for org2] *************************************
  97. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/space.yml for api.test.cf.springer-sbm.com
  98. TASK [cf : Space - Procesing space live in org2 organization] ******************
  99. ok: [api.test.cf.springer-sbm.com -> localhost]
  100. TASK [cf : Space - Facts] ******************************************************
  101. ok: [api.test.cf.springer-sbm.com -> localhost]
  102. TASK [cf : Space - Managing space org2:live present] ***************************
  103. changed: [api.test.cf.springer-sbm.com -> localhost]
  104. TASK [cf : Space - Managing security groups for org2:live] *********************
  105. included: /var/vcap/data/packages/ansible-cfsetup/130e121141cce7268e2651986b21eae4d6af91c9.1-bfdc6e9241b17fb425b68848d61379589ebb49e6/roles/cf/tasks/secgroup.yml for api.test.cf.springer-sbm.com
  106. TASK [cf : Secgroup - Procesing security group sec1] ***************************
  107. ok: [api.test.cf.springer-sbm.com -> localhost]
  108. TASK [cf : Secgroup - Facts] ***************************************************
  109. ok: [api.test.cf.springer-sbm.com -> localhost]
  110. TASK [cf : Secgroup - Managing security group sec1: present] *******************
  111. TASK [cf : Secgroup - Setting up security group rules] *************************
  112. TASK [cf : Secgroup - Managing sec1 in space live] *****************************
  113. changed: [api.test.cf.springer-sbm.com -> localhost]
  114. TASK [cf : Space - Assigning developers to org2:live] **************************
  115. TASK [cf : Space - Assigning managers to space org2:live] **********************
  116. changed: [api.test.cf.springer-sbm.com -> localhost] => (item={u'name': u'claudio@hola.com'})
  117. TASK [cf : Space - Assigning auditors to space org2:live] **********************
  118. TASK [cf : Org - Deleting spaces for org2] *************************************
  119. TASK [cf : Org - Deleting organization org2] ***********************************
  120. TASK [cf : Org - Create private domains to organization org2] ******************
  121. TASK [cf : Org - Assigning users to organization org2] *************************
  122. TASK [cf : Org - Assigning managers to organization org2] **********************
  123. TASK [cf : Org - Assigning auditors to organization org2] **********************
  124. TASK [cf : Org - Assigning billing_managers to organization org2] **************
  125. TASK [cf : Org - Assigning default organization org2 for requested users] ******
  126. PLAY RECAP *********************************************************************
  127. api.test.cf.springer-sbm.com : ok=38 changed=14 unreachable=0 failed=0
  128. Playbook run took 0 days, 0 hours, 0 minutes, 16 seconds
  129. [stderr]
  130. None
  131. Errand 'ansible-cfsetup' completed successfully (exit code 0)

Of course, you can include the errand in the Cloud Foundry manifest, in the same
way as the smoke tests.

Updating the role

The source code is a submodule of this repo, get it by running:

  1. git submodule init
  2. git submodule update

All the functionality is provided by: https://github.com/SpringerPE/ansible-cloudfoundry-role
The role is re-usable outside this release by re-defining a inventory with the variables
and a group_vars folder. Have a look at the examples on its repository.

All actions/playbooks (thanks to ansible) are idempotent.

To create a final release run: ./bosh_final_release

Author

SpringerNature Platform Engineering,
José Riguera López (jose.riguera@springer.com)

Copyright 2017 Springer Nature

License

Apache 2.0 License