1 | <?php |
||
5 | class ChefEc2 |
||
6 | { |
||
7 | /** |
||
8 | * @var string The base command for knife. |
||
9 | */ |
||
10 | private $baseKnifeCommand; |
||
11 | |||
12 | /** |
||
13 | * @var string The url for the chef API. |
||
14 | */ |
||
15 | private $chefServerUrl; |
||
16 | |||
17 | /** |
||
18 | * @var array The credentials needed to interact with knife-ec2. |
||
19 | */ |
||
20 | private $credentials; |
||
21 | |||
22 | /** |
||
23 | * Initialize the wrapper around knife-ec2. |
||
24 | * |
||
25 | * @param string $baseKnifeCommand The base command for knife. could be 'knife' if knife is already in the path. |
||
26 | * If using bundler to install knife-ec2, you could do something |
||
27 | * like 'BUNDLE_GEMFILE=/path/to/Gemfile bundle exec knife'. |
||
28 | * @param string $chefServerUrl The url for the chef API. |
||
29 | * @param array $credentials The credentials needed to interact with knife-ec2. Includes awsAccessKeyId and |
||
30 | * awsSecretAccessKey. |
||
31 | */ |
||
32 | public function __construct(string $baseKnifeCommand, string $chefServerUrl, array $credentials) |
||
38 | |||
39 | /** |
||
40 | * Instantiate a new server. |
||
41 | * |
||
42 | * @param string $region The AWS region the server is in. |
||
43 | * @param string $ami The region-specific AMI to use. |
||
44 | * @param string $flavor The flavor of server to create, e.g. t1.micro. |
||
45 | * @param array $runList The roles/recipes for the chef run list. |
||
46 | * @param string $progressFile A file path to store the server output in. |
||
47 | * @param array $options Additional options for knife-ec2. For example: ['-groups' => 'foo'] |
||
48 | * @param array $tags Tags to set for the server. |
||
49 | * @param string $chefVersion The chef version to use to bootstrap the server. |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function createServer( |
||
86 | |||
87 | /** |
||
88 | * Runs chef client on the servers that match the query storing command output in the given file. |
||
89 | * |
||
90 | * @param string $query The chef query to specify what servers to update. |
||
91 | * @param string $progressFile The filename to send the knife output to. |
||
92 | * @param array $options Additional options for knife ssh. For example: ['-groups' => 'foo'] |
||
93 | * @param array $chefOptions Additional options for chef client. For example: ['--override-runlist' => 'role[foo]'] |
||
94 | * @return void |
||
95 | */ |
||
96 | public function updateServers( |
||
118 | |||
119 | /** |
||
120 | * Get the knife-ec2 parameters for basic AWS API credentials. |
||
121 | * |
||
122 | * @return array The parameters to access AWS via knife-ec2. |
||
123 | */ |
||
124 | private function awsCredentialParameters() : array |
||
131 | |||
132 | /** |
||
133 | * Get the chef client parameters. |
||
134 | * |
||
135 | * @return array The parameters to access the chef API via knife. |
||
136 | */ |
||
137 | private function chefClientParameters() : array |
||
145 | |||
146 | /** |
||
147 | * Get the EC2 SSH parameters. |
||
148 | * |
||
149 | * @return array The parameters to access the EC2 ssh servers |
||
150 | */ |
||
151 | private function ec2SshParameters() : array |
||
158 | } |
||
159 |