Revision b9954290

View differences:

README.md
120 120
in the moment the `gen-rspec.py` command is executed. For this reason the
121 121
suggested best practice is to execute `gen-rspec.py` just before allocating the
122 122
resources using the `reserve.py` command.
123

  
124
## Generating SSH and Ansible config
125

  
126
After generating the `rspec` file, the `gen-config.py` script can generate
127
the SSH and the ansible configuration files to access the nodes of the
128
testbeds. To do so, simply run:
129

  
130
```
131
./gen-config.py -r <rspec file> -k <identity file>
132
```
133

  
134
The identity file is the private key or the certificate obtained after getting
135
an account from the [iMinds authority](https://authority.ilabt.iminds.be/).
136

  
137
This will generate:
138
* `ssh-config`: the configuration file to be given to the SSH command (e.g.,
139
  `ssh -F ssh-config ...`). This defines the names of the hosts as `node<i>`,
140
  for `i` going from 0 to N-1. To connect to one host, you can thus run
141
  `ssh -F ssh-config node0`.
142
* `ansible.cfg`: the Ansible configuration file.
143
* `ansible-hosts`: the Ansible inventory (list of nodes). In this file the
144
  group of nodes reserved for the experiments is named `nodes`. To test that
145
  this is properly working, try with `ansible nodes -m shell -a "uptime"`.
146

  
147
The filename of the configuration files can be changed via command line
148
arguments (see `./gen-config.py --help`).
gen-config.py
15 15
parser.add_argument("-s", "--ssh-config", dest="ssh_config",
16 16
                    default="ssh-config", action="store", metavar="FILENAME",
17 17
                    help="Output file onto which the SSH configuration is "
18
                         "written")
18
                         "written (default=%(default)s)")
19 19
parser.add_argument("-a", "--ansible-config", dest="ansible_config",
20 20
                    default="ansible.cfg", action="store", metavar="FILENAME",
21 21
                    help="Output file onto which the ansible configuration is "
22
                         "written")
22
                         "written (default=%(default)s)")
23 23
parser.add_argument("-i", "--inventory", dest="ansible_inventory",
24 24
                    default="ansible-hosts", action="store", metavar="FILENAME",
25 25
                    help="Output file onto which the ansible inventory is "
26
                         "written")
26
                         "written (default=%(default)s)")
27
parser.add_argument("-k", "--key", dest="identity",
28
                    default=IDENTITY_FILE, action="store",
29
                    metavar="FILENAME",
30
                    help="Private key or certificate used for the "
31
                         "authentication (default=%(default)s)")
27 32

  
28 33
args = parser.parse_args()
29 34

  
......
35 40
ssh_config_file = args.ssh_config
36 41
ansible_config_file = args.ansible_config
37 42
ansible_inventory_file = args.ansible_inventory
43
identity_file = args.identity
38 44

  
39 45
config_file = open(ssh_config_file, "w")
40 46
ansible_file = open(ansible_config_file, "w")
41 47
inventory_file = open(ansible_inventory_file, "w")
42 48

  
43
ssh_config = SSHConfig(SSH_CONFIG_TEMPLATE, HOST_CONFIG_TEMPLATE, IDENTITY_FILE)
49
ssh_config = SSHConfig(SSH_CONFIG_TEMPLATE, HOST_CONFIG_TEMPLATE, identity_file)
44 50
ansible_config = AnsibleConfig(ANSIBLE_CONFIG_TEMPLATE,
45 51
                               INVENTORY_CONFIG_TEMPLATE,
46
                               ANSIBLE_HOST_TEMPLATE, IDENTITY_FILE,
52
                               ANSIBLE_HOST_TEMPLATE, identity_file,
47 53
                               ansible_inventory_file, ssh_config_file)
48 54

  
49 55
xml_file = ET.iterparse(rspec_file)

Also available in: Unified diff