Transferring files between nodes

Dear Chefers,

Seasons Greetings.

I have the following requirement and would like your advise.

Setup
Role A creates/configures Node A
Role B creates/configures Node B

As part of Role A, i.e. within its recipe/cookbook, I am generating a server certificate (a file in some directory, on Node A). This certificate content is dynamic i.e I can’t know beforehand what its contents will be.

Requirement
Now, as part of creating/configuring Node B, I need to import the certificate/file created in Node A.

How do I achieve this copy-file-from-NodeA-and-place-it-into-NodeB activity as part of running RoleB cookbooks/recipes.

Not a requirement
Although it likely makes sense, I DO NOT have a requirement that if the file changes on Node A, that Node B somehow gets notified. In this instance, I simply want to copy the file from Node A to Node B without knowing the contents beforehand (i.e. cant use a template)

Timing
Node B will be built immediately after Node A has completed.

FTP service is not enabled on Node A, but I can think of enabling it if that is required as a possible solution.

Thanks for the help.

Regards
Aravind

I have now implemented the above using an execute block and a sftp command within.

If there are better ways to achieve this in Chef, please do let me know.

Yes, there’s a better way.

Use an internal Authority Certification, and tell node A to request a certificate to this AC.
Then the node B has just to trust the AC certificate to authenticate the node A certificate.

Obviously the AC has to exist and you have to distribute it to your nodes so they can trust it, the automation of certificate requests is a subject on itself too.

T.L.,D.R.: This is a whole subject on itself on how to manage certificate and is IMO far too complex to teach on this mailing list, I can give a lot of links but google should drive you properly too with the few keywords above.