Sorry for the general and vague nature of my question. Let me describe with some more detail what I would like to do (or what I think I would like to do).

I have a shell script for ubuntu 16.04 that sets up my instance how I want it. But it needs to use two different variable inputs for each different instance. For example, if across all the instances that I wanted to set up, I wanted to put in different timezone, I could start with a list of all the timezones, and iteratively deploy a machine for each timezone. Maybe the solution I look for would drop a textfile with the timezone I wanted on each instance. That would be enough for me to read the file and set it up. I just need a solution that will allow me to create any number of cloud instances of ubuntu 16.04 and deliver seperate textfiles with these timezones. They are all identical except the file with the timezone.

I'd like to be able to create all these instances simultaneously from the command line or through some R package for an API interface. Digital Ocean, AWS, or even some local option if I should be considering that.

Is this a job for docker or vagrant? What is the tool for this kind of deployment? Maybe a script to loop through creating instances with these?

1 Answer 1


This is why configuration management software exists. Example for Ansible and AWS:

- name: Create a sandbox instance
  hosts: localhost
  gather_facts: False
    timezones_path: /some/path/timezones.list
    key_name: my_keypair
    instance_type: m1.small
    security_group: my_securitygroup
    vpc_subnet: my_vpc_id
    image: my_ami_id
    region: us-east-1
    - name: Load timezones list
      shell: "echo {{ item }}"
      with_lines: "cat {{ timezones_path|quote }}"
      register: timezones

    - name: Launch instances
         key_name: "{{ keypair }}"
         group: "{{ security_group }}"
         instance_type: "{{ instance_type }}"
         image: "{{ image }}"
         wait: true
         region: "{{ region }}"
         vpc_subnet_id: "{{ vpc_subnet }}"
         assign_public_ip: yes
         count: "{{ timezones|length }}"
      register: ec2

    - name: Add new instance to host group
        hostname: "{{ item.1.public_ip }}"
        timezone: "{{ item.0 }}"
        groupname: launched
        "{{ timezones }}"
        "{{ ec2.instances }}"

    -name: Tag instances with timezones
        region: "{{ region }}"
        resource: "{{ item.id }}"
          Timezone: "{{ item.timezone }}"
      with_items: "{{ groups['launched'] }}"

    - name: Wait for SSH to come up
        host: "{{ item.public_dns_name }}"
        port: 22
        delay: 60
        timeout: 320
        state: started
      with_items: "{{ ec2.instances }}"

- name: Configure instance(s)
  hosts: launched
  become: True
  gather_facts: True
    - name: Run deploy script
      shell: "/path/to/script.sh --tz {{timezone}}"

Path to script in last line should be for host which runs Ansible, not remote.

  • Thanks! Ansible is the next buzzword I will be reading up on.
    – cylondude
    Jun 16, 2017 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.