0

In any fresh CentOS 7 installation, all the commands (ls, host, etc.) stop working and am getting the following messages:

-bash: /bin/host: /lib64/ld-linux-x86-64.so.2: bad ELF interpreter: No such file or directory

I have tried installing:

  • redhat-lsb
  • elfutils
  • "Compatibility libraries"

But no luck till now. Could you please what is going on wrong ? Every system deployed gets damaged at some random point in time with the above message.

EDIT: this is how I setup my systems:


  - name: linux-cfg
    hosts: all
    roles:
      - linux

    become: yes
    become_user: root
    become_method: sudo


    tasks:

      # modprobe 8021q
      # modprobe --first-time bonding
      - name: "Deactivate NetworkManager"
        systemd: name=NetworkManager enabled=no state=stopped

      - name: "Deactivate firewalld"
        systemd: name=firewalld enabled=no state=stopped

      - name: "Disable SSH login as root"
        replace: dest=/etc/ssh/sshd_config regexp='(.*)PermitRootLogin(.*)' replace='PermitRootLogin no'

      - name: "Disable DNS lookup upon SSH"
        replace: dest=/etc/ssh/sshd_config regexp='#UseDNS yes' replace='UseDNS no'

      - name: "Configure the search domain"
        lineinfile: dest=/etc/resolv.conf line="search {{ dns.name }}" state=present

      - name: "Configure the nameservers"
        lineinfile: dest=/etc/resolv.conf line="nameserver {{ item }}" state=present
        with_items: "{{ dns.servers }}"

      # - name: "Set the remote syslog server"
      #   lineinfile: dest=/etc/rsyslog.conf line="*.* @@{{ item }}:514" state=present
      #   with_items: "{{ syslog.servers }}"

      - name: "Set the timezone on CentOS"
        shell: timedatectl set-timezone Europe/Amsterdam ; hwclock --hctosys --utc ;

      - name: "Set SELinux in 'permissive' mode"
        replace: dest=/etc/sysconfig/selinux regexp='SELINUX=enforcing' replace='SELINUX=permissive'

      - name: "Disable zeroconf route"
        lineinfile: dest=/etc/sysconfig/network line="NOZEROCONF=yes" state=present

      - name: "Update system packages"
        yum: name=* state=latest
        environment:
          http_proxy: "{{ prx.http }}"
          https_proxy: "{{ prx.https }}"

      - name: "Install EPEL repository"
        yum: name=epel-release state=latest
        environment:
          http_proxy: "{{ prx.http }}"
          https_proxy: "{{ prx.https }}"

      - name: "Clear the yum caches"
        command: "yum clean all"

      - name: "Install system packages"
        yum: name="{{ item }}" state=latest
        with_items:
          - libselinux-python
          - bash-completion
          - net-tools
          - bind-utils
          - bridge-utils
          - iptraf-ng
          - net-snmp
          - net-snmp-utils
          - net-snmp-devel
          - iotop
          - htop
          - sysstat
          - lsof
          - tcpdump
          - strace
          - psmisc
          - watchdog
          - telnet
          - wget
          - nc
          - whois
          - unzip
          - git
          - colordiff
          - tree
          - subnetcalc

          - gcc
          - libxml2-devel
          - libxslt-devel
          - openssl
          - libffi-devel
          - ansible

          - erlang
          - java-1.8.0-openjdk

          # - qemu-kvm
          # - qemu-img
          # - virt-manager
          # - libvirt
          # - libvirt-python
          # - libvirt-client
          # - virt-install
          # - virt-viewer
          # - python-lxml
        environment:
          http_proxy: "{{ prx.http }}"
          https_proxy: "{{ prx.https }}"

      - name: "Configure SNMP settings"
        template: src=roles/linux/templates/snmpd.conf.j2 dest=/etc/snmp/snmpd.conf owner=root group=root mode=0600

      # - name: "Tune system settings: system.conf"
      #   replace: dest="/etc/systemd/system.conf" regexp='(.*)LogLevel=(.*)' replace='LogLevel=info'

      - name: "Enable persistent boot information in '/var/log/journal'"
        file: path="/var/log/journal" state=directory

      - name: "Enable persistent boot information in '/etc/systemd/journald.conf'"
        replace: dest="/etc/systemd/journald.conf" regexp='(.*)Storage=(.*)' replace='Storage=persistent'

      - name: "Create user netops"
        user: name="{{ secrets.USR_OPS }}" password="{{ secrets.PASS_OPS }}" createhome=yes shell=/bin/bash state=present

      - name: "Create the 'netops' directory"
        file: path="{{ dir.netops }}" state=directory owner=app group=app mode=777

      - name: "Schedule the required administration safeguard"
        cron: name="netops automation app" minute="00" job="find {{ dir.netops }} /* -mtime +30 -delete > /dev/null 2>&1" state=present

      - name: "Edit MOTD"
        copy: src=roles/linux/files/motd dest=/etc/motd owner=root group=root mode=644

and

---


  - name: python-cfg
    hosts: all
    roles:
      - linux

    become: yes
    become_user: root
    become_method: sudo


    tasks:

      - name: "Install system packages"
        yum: name="{{ item }}" state=latest
        with_items:
          - python34
          - python34-setuptools
          - python34-devel
        environment:
          http_proxy: "{{ prx.http }}"
          https_proxy: "{{ prx.https }}"

      - name: "Install Python (3) package index"
        easy_install: executable=easy_install-3.4 name=pip state=latest
        environment:
          http_proxy: "{{ prx.http }}"
          https_proxy: "{{ prx.https }}"

      - name: "Install Python (3) libraries"
        pip: executable=pip3 name="{{ item }}" state=present
        with_items:
          - ipython
          - pyyaml
          - psutil
          - requests
          - pycounters
          - arrow
          # - pandas
          - marshmallow
          - junos-eznc
          - easysnmp
          - celery
          - flask
          # - hug
          # - curio
          # - uvloop
          - gunicorn
          - redis
          - psycopg2
          - peewee
          - prometheus_client
        environment:
          http_proxy: "{{ prx.http }}"
          https_proxy: "{{ prx.https }}"

UPDATE:

the issue was because of the "space" in the below crontab

find {{ dir.netops }} /* -mtime +30 -delete

am sorry guys ..

  • What did you do prior to this happening? What do you mean with "Every system deployed gets damaged at some random point in time with the above message."? What extra software / extra repositories do you have installed/enabled? – Andreas Rogge Feb 8 '18 at 0:15
  • now, that I am looking at it, the net-snmp could be the one .. let me check – nskalis Feb 8 '18 at 1:11
  • Use selinux to set SELinux state, rather than editing a file with replace. Don't run shell commands -- or replace! -- to do things that are better done other ways, such as setting the timezone; this should just be done by creating a symlink with file. – Michael Hampton Feb 8 '18 at 5:01
  • thank you guys, your suggestions were included now, see update .. – nskalis Feb 8 '18 at 11:23
  • This is not a forum; please post an answer if you have solved the problem. – Michael Hampton Feb 8 '18 at 15:09
1

To summarize what happened:

There is an ansible-defined cronjob that runs find {{ dir.netops }} /* -mtime +30 -delete. Because of the space between {{ dir.netops }} and /* this will evaluate to find [...] /bin /lib /lib64 /boot [...] -mtime +30 -delete and will delete essentially every file on the system 30 days after its "last modified" date.

This means that every system deployed using this ansible playbook will self-destruct after 30 days.

  • the crontab runs every 1h and will delete all files under /usr/local because of the space character, so the system gets destroyed in <=1h – nskalis Feb 10 '18 at 7:52
  • i switched the answer to wiki-mode so you can edit it to reflect what you found out. – Andreas Rogge Feb 10 '18 at 9:50

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.