Link to home
Start Free TrialLog in
Avatar of Ievgen Chernov
Ievgen Chernov

asked on

Deploying the host created by CloudFormation using Ansible

I've got stuck on one trivial thing. I've got an Ansible playbook:

---
- name: Build cluster
  hosts: localhost
  gather_facts: no
  roles:
    - buildcluster

- name: Run software setup
  hosts: tag_Name_{{ cluster_name }}
  gather_facts: no
  roles:
    - iso_pipeline_install

I'm setting the {{ cluster_name }} Tag on the Master node of cluster. My {{ cluster_name }} has dashes in it, but the inventory syntax accepts only underscores. And I don't know the IP address before I run the CloudFormation build. Is there any good practice to manipulate with the created server (I've got a cluster and I need to install software only on the Master Node)? Thank you in advance.
Avatar of Anthony Garcia
Anthony Garcia
Flag of United States of America image

Does your cluster name need to have dashes? Can you edit the variable to use underscore instead? If not, then maybe you can use the regex_replace filter on the hosts line where you have the cluster_name variable.
http://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#regular-expression-filters

I have never used it that way, but if it doesn't work doing it directly in that way maybe you can use the set_fact module in a task before the run software setup task, where it would use a filter to convert the cluster_name.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.