saltstack-formulas / hostsfile-formula

Use minion IDs to keep /etc/hosts and hostnames consistent for clusters without DNS
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
33 stars 88 forks source link

How to implement? #31

Open ghost opened 4 years ago

ghost commented 4 years ago

I'm currently facing some issue using saltstack to enroll my landscape. I would like that salt manages the /etc/hosts file on all my minions/servers. Therefor I added the hostsfile-formular to my saltstack via a Git-remoteFS but it seems to have no effect. No hosts file gets placed anywhere, Please also see: What i'm doing wrong here?

my tree:

root@salt:/srv# tree
.
├── formulas
├── pillar
│   ├── hostsfile.sls
│   └── timezone.sls
├── README.md
└── salt
    ├── base.sh
    ├── docker
    │   └── init.sls
    ├── fail2ban
    │   ├── init.sls
    │   ├── jail.conf
    │   └── jail.local
    ├── glusterfs
    │   └── init.sls
    ├── iptables
    │   ├── init.sls
    │   ├── nodes
    │   └── template.j2
    ├── minion
    ├── scripts
    │   ├── add_minion.sh
    │   ├── remove_minion.sh
    │   └── salt_master_enroll.sh
    ├── ssh
    │   ├── authorized_keys
    │   ├── init.sls
    │   ├── motd
    │   ├── server.sls
    │   └── sshd_config
    ├── toolstack
    │   └── init.sls
    └── top.sls

/etc/salt/minion (same on all minions):

mine_functions:
  network.interfaces: []
  network.ip_addrs:
    - enp7s0
mine_interval: 2

/etc/salt/master (salt master only)

interface: 10.10.10.2

pillar_roots:
  base:
    - /srv/pillar

fileserver_backend:
  - git
  - roots

# Add your remote formular repos here:
gitfs_remotes:
  - https://github.com/saltstack-formulas/timezone-formula.git
  - https://github.com/saltstack-formulas/hostsfile-formula.git
  - https://github.com/salt-formulas/salt-formula-glusterfs.git

gitfs_provider: gitpython

/etc/salt/top.sls:

base:           # Apply SLS files from the directory root for the 'base' environment

  '*':
    - timezone  # Set the general timezone
    - hostsfile # Set the /etc/hosts file

  'salt':       # For salt master node as there is only one
    - toolstack # Apply basic toolstack to node
...

Finally my hostsfile.sls pillar at /srv/pillar/hostsfile.sls:

hostsfile:
  domain: local
  hosts:
    salt: 10.10.10.2
    master1: 10.10.10.3
  only:
    127.0.0.1:
      - localhost
      - localhost.localdomain
    # Removes all entries for 127.0.1.1:
    127.0.1.1: []

Can smb explain to me why my hostsfile has no effect at all. What do I miss here?

daks commented 4 years ago

are you still blocked by this? Can you come ask for help on IRC #saltstack-formulas or on the saltstack slack instance on #formulas?