Skip to content

Instantly share code, notes, and snippets.

@goldyfruit
Last active March 2, 2016 21:19
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 goldyfruit/9f88760ee4382f0e993b to your computer and use it in GitHub Desktop.
Save goldyfruit/9f88760ee4382f0e993b to your computer and use it in GitHub Desktop.
[ansible] Running keystone-manage pki_setup on one host and send SSL certificates on other nodes
---
- name: Ansible tests playbook
hosts: all
remote_user: root
tasks:
- name: Running PKI setup and creating a tarball with certificates
shell:
keystone-manage pki_setup --keystone-user keystone --keystone-group keystone && \
cd /etc/keystone/ && \
tar czf ssl_keystone.tar.gz ssl/
run_once: true
- name: Fetching Keystone SSL certs
fetch:
src=/etc/keystone/ssl_keystone.tar.gz
dest=/tmp/
flat=yes
- name: Unarchiving PKI SSL files
unarchive:
src=/tmp/ssl_keystone.tar.gz
dest=/etc/keystone
owner=keystone
group=keystone
mode=0640
when: inventory_hostname != play_hosts[0]
@goldyfruit
Copy link
Author

Explanations:

  1. - Run keystone-manage pki_setup command on one node only (run_once: true)
  2. - Create a tarball with SSL certificates (/etc/keystone/ssl)
  3. - Fetch the tarball on the Ansible master
  4. - Unarchiving the tarball in /etc/keystone/ for nodes different of play_hosts[0]

run_once get the first host of the inventory or the first host of a group, so it should be equal to play_hosts[0]

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