You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rst/extra/quickstart.rst
+66-44Lines changed: 66 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,16 @@ Quickstart Guide
5
5
****************
6
6
7
7
This guide will walk users through a few foundational Ansible terms and
8
-
concepts, introduce the HyperCore collection, and provide guidance on
9
-
writing playbooks.
8
+
concepts, introduce the HyperCore Collection, and provide guidance on
9
+
writing Playbooks.
10
10
11
11
Introduction
12
12
=============
13
13
Scale Computing recently launched the SC//HyperCore Collection for Ansible. This exciting tool gives MSPs and distributed edge
14
14
organizations the ability to implement declarative configuration
15
15
management in their HyperCore fleet. Ansible is an IT automation tool
16
-
designed to automate server provisioning and management via playbooks.
17
-
These playbooks are similar to scripts, but have two key benefits,
16
+
designed to automate server provisioning and management via Playbooks.
17
+
These Playbooks are similar to scripts, but have two key benefits,
18
18
namely: they are human readable and idempotent, meaning they can be run
19
19
several times and are smart enough to only take actions that are
20
20
required (and skip those that aren't) to put a HyperCore cluster in the
@@ -24,7 +24,7 @@ HyperCore fleets.
24
24
.. note::
25
25
Ansible is an open source tool maintained by Red Hat. It is
26
26
completely free to install and use. ScaleCare support may
27
-
provide best-effort assistance in writing playbooks and
27
+
provide best-effort assistance in writing Playbooks and
28
28
diagnosing issues.
29
29
30
30
However, the HyperCore Collection for Ansible is fully
@@ -36,7 +36,7 @@ HyperCore fleets.
36
36
Overview and Terminology
37
37
========================
38
38
39
-
Before you can begin writing playbooks and automating HyperCore
39
+
Before you can begin writing Playbooks and automating HyperCore
40
40
management, we must first cover a few important concepts. First, it is
41
41
important to note that Ansible is a powerful tool that gives users the
42
42
ability to accomplish the same task in a myriad of different ways. It
@@ -47,8 +47,8 @@ with Ansible.
47
47
Second, Ansible commands need to be run from an "Ansible Server" (also
48
48
called an "Ansible Control Host"). In some cases, this is actually a
49
49
dedicated physical server or VM, however this is not always necessary.
50
-
Users can run ansible from a workstation, this local machine contains
51
-
the necessary playbooks to run against the servers being managed.
50
+
Users can run Ansible from a workstation, this local machine contains
51
+
the necessary Playbooks to run against the servers being managed.
52
52
53
53
Third, Open SSH is the default communication standard used by Ansible
54
54
for remote administration. Crucially, this is not how Ansible will
@@ -60,7 +60,7 @@ Inventory
60
60
61
61
Ansible is incredibly useful for managing many HyperCore clusters.
62
62
Ansible relies on an inventory file to establish which clusters you want
63
-
to target with your playbooks. This file is most commonly formatted in
63
+
to target with your Playbooks. This file is most commonly formatted in
64
64
either INI or YAML and lists your clusters. For larger organizations,
65
65
the inventory is also the ideal location to organize your fleet,
66
66
particularly when you desire different cluster states based on different
@@ -94,7 +94,7 @@ something like this:
94
94
Ansible Configuration File
95
95
---------------------------
96
96
97
-
When running Ansible commands and writing playbooks it is important to
97
+
When running Ansible commands and writing Playbooks it is important to
98
98
specify where your inventory is and other configuration specifics, like
99
99
your Ansible collection path. This file serves as the center to all of
100
100
your server interactions.
@@ -104,13 +104,13 @@ configuration file **(ansible.cfg)**. The default configuration is a large
104
104
file that you can choose to use, however it is also fine to create your
105
105
own simplified version. The most important thing is to make sure your
106
106
work is referencing the correct configuration file. The easiest way to
107
-
achieve this is by including an ansible.cfg in the directory where you
107
+
achieve this is by including an **ansible.cfg** in the directory where you
108
108
are working with Ansible or setting it as an environment variable.
109
109
110
110
For the purposes of this guide, you need to make sure your configuration
111
111
file specifies where your inventory is located. All that is required is
112
-
to set ``inventory = [folder that contains your inventory in your working
113
-
ansible directory]``. You can reference a specific file or an entire
112
+
to set ``inventory`` = [folder that contains your inventory in your working
113
+
ansible directory]. You can reference a specific file or an entire
114
114
inventory folder. An example of a simple configuration file looks like
115
115
this:
116
116
@@ -120,11 +120,11 @@ Ansible Module
120
120
--------------
121
121
122
122
Now that you are familiar with Ansible inventories and configuration
123
-
files we can turn to the meat of Ansible and the HyperCore collection:
123
+
files we can turn to the meat of Ansible and the HyperCore Collection
124
124
modules. Ansible Modules are units of code that can control the servers
125
125
that you are managing with Ansible. After installing Ansible, you will
126
126
have access to a library of modules that give you the ability to execute
127
-
specific tasks on remote servers through playbooks and individual
127
+
specific tasks on remote servers through Playbooks and individual
128
128
commands. Scale Computing has made managing your HyperCore fleet via
129
129
Ansible possible by developing our own set of modules that call existing
130
130
cluster REST API endpoints. Extensive documentation on our current
@@ -133,54 +133,61 @@ available modules can be found
133
133
134
134
For example: `scale_computing.hypercore.vm <https://scalecomputing.github.io/HyperCoreAnsibleCollection-docs/modules/vm.html>`_
135
135
is the module that will allow you to create, update, and delete virtual
136
-
machines. When you begin writing playbooks, you will reference a specific
136
+
machines. When you begin writing Playbooks, you will reference a specific
137
137
module when attempting to automate a task associated with that said module
138
138
is equipped to handle.
139
139
140
140
Ansible Playbook
141
141
-----------------
142
142
143
-
Finally, playbooks are the most important piece of Ansible. Playbooks
143
+
Finally, Playbooks are the most important piece of Ansible. Playbooks
144
144
allow you to automate tasks that would normally need to be done more
145
145
than once across the clusters in your fleet. While similar to scripts,
146
-
playbooks are much easier to write because they are human readable.
146
+
Playbooks are much easier to write because they are human readable.
147
147
Additionally, we have in-depth documentation about every module
148
148
available in the Ansible collection, with specific examples of how each
149
-
module can be written as a task that is part of a playbook.
150
-
Additionally, playbooks and Ansible are idempotent, meaning that they
149
+
module can be written as a task that is part of a Playbook.
150
+
Additionally, Playbooks and Ansible are idempotent, meaning that they
151
151
are smart enough to know if a cluster already has a desired
152
152
configuration and skip tasks that do not need repeated.
153
153
154
-
At a high level, playbooks typically begin with the author specifying
154
+
At a high level, Playbooks typically begin with the author specifying
155
155
which hosts (in our case HyperCore clusters) are going to be targeted.
156
156
They will then establish the method by which Ansible will connect to the
157
157
remote hosts (in our case this will be ``connection:
158
158
ansible.builtin.local``). Once these have been established, the author
159
159
can begin writing tasks in the order in which they will be carried out;
160
-
calling out the necessary ansible modules and module parameters along
160
+
calling out the necessary Ansible modules and module parameters along
161
161
the way.
162
162
163
163
In a future section, you will get an overview of how to start writing
164
-
your own playbooks.
164
+
your own Playbooks.
165
165
166
166
Ansible Installation
167
167
====================
168
168
169
-
Now that you have a basic understanding of key Ansible concepts we can turn to installing Ansible and the HyperCore collection.
169
+
Now that you have a basic understanding of key Ansible concepts we can turn to installing Ansible and the HyperCore Collection.
170
170
171
171
.. note::
172
-
Your ansible server (where you run your commands) must be a UNIX-like machine with Python 3.8 or newer. This guide uses an
172
+
Your Ansible server (where you run your commands) must be a UNIX-like machine with Python 3.8 or newer. This guide uses an
173
173
Ubuntu 20.04 virtual machine to demonstrate how to install Ansible.
174
174
175
-
1. Install ansible ``sudo apt install ansible``
176
-
a. This command will install of the ncessary packages, libraries, and bianaries needed to run Ansible.
177
-
2. Now that you have installed Ansible, you need to install the HyperCored Collection with this command: ``ansible-galaxy collection install scale_computing.hypercore``
178
-
a. Installing the HyperCore collection will give you access to all of the modules we have built to allow you to automate tasks within HyperCore.
179
-
b. Full documentation on our collection can be found at `Ansible galaxy <https://galaxy.ansible.com/scale_computing/hypercore>`_.
175
+
1. Install Ansible:
176
+
``sudo apt install ansible``
177
+
178
+
a. This command will install of the necessary packages, libraries, and bianaries needed to run Ansible.
179
+
180
+
2. Now that you have installed Ansible, you need to install the HyperCore Collection with this command:
a. Installing the HyperCore Collection will give you access to all of the modules we have built to allow you to automate tasks within HyperCore.
184
+
185
+
b. Full documentation on our collection can be found at `Ansible galaxy <https://galaxy.ansible.com/scale_computing/hypercore>`_.
180
186
181
187
.. image:: images/qs_install1.png
182
188
183
-
3. You are now ready to start using Ansible with your HyperCore clusters! Before turning to writing Playbooks, you can test that the collections was successfully installed by running single-module commands.
189
+
3. You are now ready to start using Ansible with your HyperCore clusters! Before turning to writing Playbooks, you can test that the collection was successfully installed by running single-module commands.
190
+
184
191
4. Specify a HyperCore cluster to test an Ansible module against with the following commands:
185
192
186
193
.. code-block:: shell
@@ -191,30 +198,35 @@ Now that you have a basic understanding of key Ansible concepts we can turn to i
191
198
192
199
.. image:: images/qs_install2.png
193
200
194
-
5. You can now run your first Ansible command against the test cluster you previously specified! Enter the following command:
201
+
5. You can now run your first Ansible command against the test cluster you previously specified!
202
+
203
+
Enter the following command:
195
204
``ansible -i localhost, --connection=ansible.builtin.local all -m scale_computing.hypercore.vm_info``
196
205
197
206
This command is targeting your local host *(localhost)*, using the required connection protocol for HyperCore clusters instead of default ssh *(--connection=ansible.builtin.local)*, using the ``scale_computing.hypercore.vm_info`` module. If successful, this command should return information about every VM running on your target cluster.
198
207
199
208
.. image: images/qs_install3.png
200
209
201
-
Congratulations! You have successfully installed Ansible and the HyperCore collection. The next section will walk you through setting up a basic inventory file and writing a playbook.
210
+
Congratulations! You have successfully installed Ansible and the HyperCore Collection. The next section will walk you through setting up a basic inventory file and writing a Playbook.
202
211
203
212
Getting Started with Playbooks
204
213
==============================
205
214
206
-
With Ansible and the HyperCore collection downloaded and installed, you are now ready to start writing your own Playbooks. As mentioned earlier, playbooks are essentially scripts that automate a series of tasks to be run against your HyperCore fleet. However, playbooks are much easier to write than normal scripts because they are simply YAML-formatted text files that are interpreted by Ansible.
215
+
With Ansible and the HyperCore Collection downloaded and installed, you are now ready to start writing your own Playbooks. As mentioned earlier, Playbooks are essentially scripts that automate a series of tasks to be run against your HyperCore fleet. However, Playbooks are much easier to write than normal scripts because they are simply YAML-formatted text files that are interpreted by Ansible.
207
216
208
217
While exporting HyperCore cluster information at the command line works perfectly fine for one-off Ansible commands (like in the previous section), Playbooks rely on an inventory file to establish which clusters are in your fleet and are automated. In order to get started writing Playbooks, you should first create an inventory file in the directory where you downloaded and installed Ansible and the HyperCore Collection.
209
218
210
-
1. Create a folder called ``/inventory``
211
-
2. Create a file called ``inventory`` within this folder
212
-
a. Inventory files can be YAML, JSON, and INI formatted.
219
+
1. Create a folder called ``/inventory``.
220
+
221
+
2. Create a file called ``inventory`` within this folder.
222
+
223
+
a. Inventory files can be YAML, JSON, and INI formatted.
213
224
214
225
.. note:: This can be done easily via a text editor like nano or a source-code editor like Visual Studio Code (VSC).
215
226
216
-
b. This example includes groups (which are entirely optional), but demonstrate how an inventory file could be used to organize a larger fleet.
217
-
c. Here is a handy reference for `creating more complex inventory files <https://docs.ansible.com/ansible/2.5/user_guide/intro_inventory.html>`_.
227
+
b. This example includes groups (which are entirely optional), but demonstrate how an inventory file could be used to organize a larger fleet.
228
+
229
+
c. Here is a handy reference for `creating more complex inventory files <https://docs.ansible.com/ansible/2.5/user_guide/intro_inventory.html>`_.
218
230
219
231
.. code-block:: yaml
220
232
@@ -238,11 +250,14 @@ In the previous section, you created an inventory that contains one cluster. Ple
238
250
Due to the flexibility of Ansible, you will also need to create an Ansible Configuration file to set your defaults, like calling out which inventory Ansible should reference. For the purposes of this guide, you only need to make sure your configuration file specifies that your inventory is equal to the folder that contains your inventory in your working Ansible directory.
239
251
240
252
1. Create new file called ``ansible.cfg`` in the directory you are using for Ansible.
253
+
241
254
2. Open an editing tool and create the following:
242
255
243
256
.. image:: images/qs_gstarted.png
244
257
245
-
3. This file allows you to set basic Ansible defaults, more importantly, you are instructing Ansible to reference your "inventory" file that you created in the previous step. **Note** this can be a full file path if you are referencing a specific file or simply call out the entire folder (if you are distributing your inventory amongst several files). In this case it does not really matter since you only have one file in your inventory folder.
258
+
3. This file allows you to set basic Ansible defaults, more importantly, you are instructing Ansible to reference your ``inventory`` file that you created in the previous step.
259
+
260
+
.. note:: This can be a full file path if you are referencing a specific file or simply call out the entire folder (if you are distributing your inventory amongst several files). In this case it does not really matter since you only have one file in your inventory folder.
246
261
247
262
With basic inventory and ``ansbile.cfg`` files created, we can now begin writing Playbooks.
248
263
@@ -252,20 +267,26 @@ Writing Playbooks
252
267
This guide will now demonstrate how to create a Playbook that will create a VM on your test cluster.
253
268
254
269
1. Create a new file called ``simple_vm_create.yml`` in the directory you are using for Ansible.
270
+
255
271
2. Open an editing tool and begin your Playbook with the following:
256
272
257
273
.. image:: images/qs_wplaybooks1.png
258
274
259
275
.. note:: All YAML files, including Playbooks, begin with "---" and the information that specifies the purpose of the Playbook. This identifies host targets, whether to gather basic facts about the target hosts, and how Ansible will communicate with those targets. Remember, SSH is the default protocol used by Ansible, so when writing Playbooks with the HyperCore Collection, you should specify ``ansible.builtin.local``.
260
276
261
277
3. After specifying this information, you can start adding tasks to your Playbook
262
-
4. A few lines after your introduction block of test write ``tasks:``
278
+
279
+
4. A few lines after your introduction block of test write
280
+
``tasks:``.
281
+
263
282
a. This line tells Ansible that the text below will outline specific actions to be performed.
283
+
264
284
b. ``tasks:`` should be lined up directly below ``gather_facts: False``
265
285
266
286
.. image:: images/qs_wplaybooks2.png
267
287
268
288
5. Each individual task in a Playbook shoule begin with ``- name:`` and a concise name that explains the purpose of that task. This name helps you understand what each task in a Playbook is attempting to accomplish.
289
+
269
290
6. The next line specifies which module you are using from the HyperCore Collecction to archieve the task. Right now the HyperCore Collection contains 19 individual modules that facilitate actions related to workload lifecycle management.
270
291
The best place to start with writing and formatting tasks using these modules is our `published documentation <https://galaxy.ansible.com/scale_computing/hypercore>`_.
271
292
At this link, you will find clear explanations of what each module enables and examples on how to correctly write a task with each module.
@@ -318,10 +339,11 @@ This guide will now demonstrate how to create a Playbook that will create a VM o
318
339
register: result
319
340
320
341
8. After copying and pasting the task into your editor of choice you only need to make a few changes to run the Playbook.
321
-
a. First, directly under ``scale_computing.hypercore.vm:``, insert a new code block that looks like this:
342
+
343
+
a. First, directly under ``scale_computing.hypercore.vm:``, insert a new code block that looks like this:
322
344
323
345
.. image:: images/qs_wplaybooks4.png
324
-
:alt:This is how we tell the playbook to reference our inventory file and includes our target host and the variables for HyperCore user and password.
346
+
:alt:This is how we tell the Playbook to reference our inventory file and includes our target host and the variables for HyperCore user and password.
325
347
326
348
b. Second, delete the following section entirely:
327
349
@@ -365,7 +387,7 @@ b. If successful, you will see an output at the command line that looks like thi
365
387
366
388
11. Finally, if you want to test Ansible's idempotency you can re-run the exact same Playbook again with no changes. As long as you haven't changed anything about the VM, Ansible will be able to see that the VM you desire is already on the cluster and skip creating a new one. The result is called out as ``ok`` in the play recap.
0 commit comments