Code Monkey home page Code Monkey logo

ansible-fqdn's Introduction

fqdn Build Status

Sets Fully qualified domain name (FQDN)

Requirements

Ansible version 2.0+

Platforms

  • Ubuntu
  • Debian
  • Centos
  • Redhat
  • Windows

Role Variables

Variable name Variable value Default
hostname hostname (eg. vm1) inventory_hostname_short
fqdn domain name (eg. vm1.test.com) inventory_hostname
ip_address ip address (eg. 192.168.0.20) ansible_default_ipv4.address

Example

- hosts: mx.mydomain.com:mx
  user: root

  roles:
    - { role: fqdn, fqdn: "mx.mydomain.com", hostname: "mx" }

License

MIT

Author Information

Roman Gorodeckij ([email protected]) John Brooker ([email protected])

ansible-fqdn's People

Contributors

caboteria avatar danvaida avatar gadelkareem avatar gdw2 avatar holms avatar hut8 avatar mrmeszaros avatar roumano avatar tersmitten avatar vaidik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-fqdn's Issues

add handler to avoid to always bounce the service

on need task in linux.yml i will recommand to use :
notify: - restart hostname

and create a handlers : main.yml

  • name: restart hostname
    service: name=hostname state=restarted
    async: 45
    poll: 0
    when: ansible_distribution not in [ 'RedHat', 'CentOS' ]

It's will avoid to always bounce the service and the final state result will be better ;)

What do you think ?

"include:" is deprecated starting with Ansible 2.14

I get this message when using this:

[DEPRECATION WARNING]: "include" is deprecated, use include_tasks/import_tasks instead. See https://docs.ansible.com/ansible-core/2.14/user_guide/playbooks_reuse_includes.html for details. This feature will be removed in version 2.16.    
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

`domainname` on Ubuntu 18.04 returns (none)

My playbook ran without errors but domainname still returns (none).

 ~/Code/home.b5y.gs  ✔  ssh home                                                                                                                  18.04 ● ↑3
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-29-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri Jan 25 15:02:06 GMT 2019

  System load:  0.1               Processes:              162
  Usage of /:   9.7% of 18.17GB   Users logged in:        1
  Memory usage: 1%                IP address for enp0s25: 10.0.1.254
  Swap usage:   0%

 * MicroK8s is Kubernetes in a snap. Made by devs for devs.
   One quick install on a workstation, VM, or appliance.

   - https://bit.ly/microk8s

 * Full K8s GPU support is now available!

   - https://blog.ubuntu.com/2018/12/10/using-gpgpus-with-kubernetes


 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

162 packages can be updated.
88 updates are security updates.


Last login: Fri Jan 25 14:36:03 2019 from 10.0.1.30
brad@home:~$ hostname
home
brad@home:~$ domainname
(none)
brad@home:~$

Playbook:

---
# Set hostname and domain name locally
- hosts: all
  roles:
    - role: holms.fqdn
      fqdn: "{{fullname}}"

fullname is set to home.b5y.gs

any suggestions?

Lineinfile misses pre-existing /etc/hosts entry

As per the title. tasks/linux.cf needs the following change:

lineinfile: dest=/etc/hosts line='{{ ansible_default_ipv4.address }} {{ fqdn }} {{ inventory_hostname_short }}' state=present backup=yes

should be

lineinfile: dest=/etc/hosts regexp='^{{ ansible_default_ipv4.address }}' line='{{ ansible_default_ipv4.address }} {{ fqdn }} {{ inventory_hostname_short }}' state=present backup=yes

If this is not done, a prexisting hosts entry (at first run) will take precedence over the line that ansible adds.

Reasonable defaults

Right now you specify both the FQDN and the hostname in the playbook. But for all of my cases, I just need this:

    - { role: holms.fqdn, fqdn: "{{ inventory_hostname }}", hostname: "{{ inventory_hostname_short }}" }

What about making that a default? Thoughts are appreciated.

printing correct entries in /etc/hosts

Hi , to get correct value in /etc/hosts you should use {{ hostvars[item].ansible_hostname }}.{{ fqdn }}

it will print in /etc/hosts as

10.188.0.47 one.csc.fi one ( IP FQDN HOSTNAME )

use below in default.yml

  lineinfile: dest=/etc/hosts regexp='{{ hostvars[item].ansible_hostname }}$' line='{{ hostvars[item].ansible_default_ipv4.address }} {{ hostvars[item].ansible_hostname }}.{{ fqdn }} {{ item }}' state=present backup=yes

debian 8.6

on the Debian Jessie the task restart hostname failed :

TASK [ansible-fqdn : restart hostname] *****************************************
fatal: [debian]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to restart service hostname: Failed to restart hostname.service: Unit hostname.service is masked.\n"}

On the box, it's like this :

root@test:~# systemctl status hostname
● hostname.service
Loaded: masked (/dev/null)
Active: inactive (dead)

Improve .travis.yml

Having a .travis.yml file like this one makes testing a accepting pull request more easy. You can also specify versions that are know to fail (due to bugs).

Do you want me to add something similar?

version tags

Would you mind to start versioning the role and add tags? I would like to pin a specific version in my common setup role.

(absolutely necessary in a production environment)

IPv6

Any interest in adding IPv6 support to this role? :)

Update metadata on galaxy

i successfully tested this role on Ubuntu 16.04 LTS (xenial)

could you reimport it in the galaxy so xenial is in the list of supported versions?

Custom IP address for multi-interface machines

I have a machine that has a separate Mgmt and Ops interface (and IP address).

I would need to set the IP of the fqdn entry with a custom address - not the ansible_default_ipv4.address.

This could solve #36 as one could set the address entry to an IPv6 address.

custom hostname not used

- hosts: 10.0.0.5
  roles:
    - { role: fqdn, fqdn: "mx.mydomain.com", hostname: "mx" }

/etc/hosts has the content:

10.0.0.5 mx.mydomain.com 10

but should have

10.0.0.5 mx.mydomain.com mx

Building of /etc/hosts includes wrong data

I've only been using this role when deploying to a single host. Recently that changed, and after I fixed #3 I noticed this in my /etc/hosts:

127.0.0.1       localhost
127.0.1.1       ibm704
...
1.2.3.4 ibm704.example.com ibm704
4.3.2.1 ibm704.example.com therac25

Yikes 😲 My two hosts are ibm704.example.com and therac25.example.com. So the last line above should clearly be therac25.example.com instead of ibm704.example.com right? I just upgraded the role.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.