在任何全新安装的 CentOS 7 中,所有命令(ls、host 等)都会停止工作并收到以下消息:
-bash: /bin/host: /lib64/ld-linux-x86-64.so.2: bad ELF interpreter: No such file or directory
我已尝试安装:
- 红帽 lsb
- 艾尔富提尔斯
- “兼容库”
但到现在还没有运气。你能告诉我到底出了什么问题吗?每个部署的系统都会在某个随机时间点损坏,并出现上述消息。
编辑:这是我设置系统的方式:
- 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
和
---
- 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 }}"
更新:
问题是由于下面的 crontab 中的“空格”引起的
find {{ dir.netops }} /* -mtime +30 -delete
很抱歉,各位。
答案1
总结一下发生的事情:
有一个 ansible 定义的 cronjob 运行find {{ dir.netops }} /* -mtime +30 -delete
。由于和之间的空格{{ dir.netops }}
,/*
它将评估为find [...] /bin /lib /lib64 /boot [...] -mtime +30 -delete
并将删除系统上在其“上次修改”日期之后 30 天的基本上所有文件。
这意味着使用此 ansible playbook 部署的每个系统将在 30 天后自毁。